Bug 750454 - Fix FUEL leaks. Part 8: Reformat FUEL code. r=mak

--HG--
extra : rebase_source : f60cacaef0d993a4fde695140fcd3b6fab9e8c7e
This commit is contained in:
Justin Lebar 2012-06-05 20:05:50 -04:00
parent fa5fbca01c
commit f5377cfc4f
2 changed files with 131 additions and 129 deletions

View File

@ -55,14 +55,14 @@ var Utilities = {
return this.windowMediator;
},
makeURI : function(aSpec) {
makeURI: function fuelutil_makeURI(aSpec) {
if (!aSpec)
return null;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
return ios.newURI(aSpec, null, null);
},
free : function() {
free: function fuelutil_free() {
delete this.bookmarks;
delete this.bookmarksObserver;
delete this.livemarks
@ -110,14 +110,15 @@ Window.prototype = {
* Helper used to setup event handlers on the XBL element. Note that the events
* are actually dispatched to tabs, so we capture them.
*/
_watch : function win_watch(aType) {
_watch: function win_watch(aType) {
this._tabbrowser.tabContainer.addEventListener(aType, this,
/* useCapture = */ true);
},
handleEvent : function win_handleEvent(aEvent) {
handleEvent: function win_handleEvent(aEvent) {
this._events.dispatch(aEvent.type, getBrowserTab(this, aEvent.originalTarget.linkedBrowser));
},
get tabs() {
var tabs = [];
var browsers = this._tabbrowser.browsers;
@ -125,14 +126,16 @@ Window.prototype = {
tabs.push(getBrowserTab(this, browsers[i]));
return tabs;
},
get activeTab() {
return getBrowserTab(this, this._tabbrowser.selectedBrowser);
},
open : function win_open(aURI) {
open: function win_open(aURI) {
return getBrowserTab(this, this._tabbrowser.addTab(aURI.spec).linkedBrowser);
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIWindow])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIWindow])
};
//=================================================
@ -196,12 +199,12 @@ BrowserTab.prototype = {
/*
* Helper used to setup event handlers on the XBL element
*/
_watch : function bt_watch(aType) {
_watch: function bt_watch(aType) {
this._browser.addEventListener(aType, this,
/* useCapture = */ true);
},
handleEvent : function bt_handleEvent(aEvent) {
handleEvent: function bt_handleEvent(aEvent) {
if (aEvent.type == "load") {
if (!(aEvent.originalTarget instanceof Ci.nsIDOMDocument))
return;
@ -215,33 +218,33 @@ BrowserTab.prototype = {
/*
* Helper used to determine the index offset of the browsertab
*/
_getTab : function bt_gettab() {
_getTab: function bt_gettab() {
var tabs = this._tabbrowser.tabs;
return tabs[this.index] || null;
},
load : function bt_load(aURI) {
load: function bt_load(aURI) {
this._browser.loadURI(aURI.spec, null, null);
},
focus : function bt_focus() {
focus: function bt_focus() {
this._tabbrowser.selectedTab = this._getTab();
this._tabbrowser.focus();
},
close : function bt_close() {
close: function bt_close() {
this._tabbrowser.removeTab(this._getTab());
},
moveBefore : function bt_movebefore(aBefore) {
moveBefore: function bt_movebefore(aBefore) {
this._tabbrowser.moveTabTo(this._getTab(), aBefore.index);
},
moveToEnd : function bt_moveend() {
moveToEnd: function bt_moveend() {
this._tabbrowser.moveTabTo(this._getTab(), this._tabbrowser.browsers.length);
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBrowserTab])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIBrowserTab])
};
@ -256,26 +259,26 @@ Annotations.prototype = {
return Utilities.annotations.getItemAnnotationNames(this._id);
},
has : function ann_has(aName) {
has: function ann_has(aName) {
return Utilities.annotations.itemHasAnnotation(this._id, aName);
},
get : function(aName) {
get: function ann_get(aName) {
if (this.has(aName))
return Utilities.annotations.getItemAnnotation(this._id, aName);
return null;
},
set : function(aName, aValue, aExpiration) {
set: function ann_set(aName, aValue, aExpiration) {
Utilities.annotations.setItemAnnotation(this._id, aName, aValue, 0, aExpiration);
},
remove : function ann_remove(aName) {
remove: function ann_remove(aName) {
if (aName)
Utilities.annotations.removeItemAnnotation(this._id, aName);
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIAnnotations])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIAnnotations])
};
@ -308,39 +311,38 @@ function BookmarksObserver() {
}
BookmarksObserver.prototype = {
onBeginUpdateBatch : function() {},
onEndUpdateBatch : function() {},
onBeforeItemRemoved : function(aId) {},
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
onBeforeItemRemoved: function () {},
onItemVisited: function () {},
onItemAdded : function(aId, aFolder, aIndex, aItemType, aURI) {
onItemAdded: function bo_onItemAdded(aId, aFolder, aIndex, aItemType, aURI) {
this._rootEvents.dispatch("add", aId);
this._dispatchToEvents("addchild", aId, this._folderEventsDict[aFolder]);
},
onItemVisited: function(aId, aVisitID, aTime) {},
onItemRemoved : function(aId, aFolder, aIndex) {
onItemRemoved: function bo_onItemRemoved(aId, aFolder, aIndex) {
this._rootEvents.dispatch("remove", aId);
this._dispatchToEvents("remove", aId, this._eventsDict[aId]);
this._dispatchToEvents("removechild", aId, this._folderEventsDict[aFolder]);
},
onItemChanged : function(aId, aProperty, aIsAnnotationProperty, aValue) {
onItemChanged: function bo_onItemChanged(aId, aProperty, aIsAnnotationProperty, aValue) {
this._rootEvents.dispatch("change", aProperty);
this._dispatchToEvents("change", aProperty, this._eventsDict[aId]);
},
onItemMoved: function(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
onItemMoved: function bo_onItemMoved(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
this._dispatchToEvents("move", aId, this._eventsDict[aId]);
},
_dispatchToEvents: function(aEvent, aData, aEvents) {
_dispatchToEvents: function bo_dispatchToEvents(aEvent, aData, aEvents) {
if (aEvents) {
aEvents.dispatch(aEvent, aData);
}
},
_addListenerToDict: function(aId, aEvent, aListener, aDict) {
_addListenerToDict: function bo_addListenerToDict(aId, aEvent, aListener, aDict) {
var events = aDict[aId];
if (!events) {
events = new Events();
@ -349,7 +351,7 @@ BookmarksObserver.prototype = {
events.addListener(aEvent, aListener);
},
_removeListenerFromDict: function(aId, aEvent, aListener, aDict) {
_removeListenerFromDict: function bo_removeListenerFromDict(aId, aEvent, aListener, aDict) {
var events = aDict[aId];
if (!events) {
return;
@ -360,32 +362,32 @@ BookmarksObserver.prototype = {
}
},
addListener: function(aId, aEvent, aListener) {
addListener: function bo_addListener(aId, aEvent, aListener) {
this._addListenerToDict(aId, aEvent, aListener, this._eventsDict);
},
removeListener: function(aId, aEvent, aListener) {
removeListener: function bo_removeListener(aId, aEvent, aListener) {
this._removeListenerFromDict(aId, aEvent, aListener, this._eventsDict);
},
addFolderListener: function(aId, aEvent, aListener) {
addFolderListener: function addFolderListener(aId, aEvent, aListener) {
this._addListenerToDict(aId, aEvent, aListener, this._folderEventsDict);
},
removeFolderListener: function(aId, aEvent, aListener) {
removeFolderListener: function removeFolderListener(aId, aEvent, aListener) {
this._removeListenerFromDict(aId, aEvent, aListener, this._folderEventsDict);
},
addRootListener: function(aEvent, aListener) {
addRootListener: function addRootListener(aEvent, aListener) {
this._rootEvents.addListener(aEvent, aListener);
},
removeRootListener: function(aEvent, aListener) {
removeRootListener: function removeRootListener(aEvent, aListener) {
this._rootEvents.removeListener(aEvent, aListener);
},
QueryInterface : XPCOMUtils.generateQI([Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
};
//=================================================
@ -414,13 +416,13 @@ function Bookmark(aId, aParent, aType) {
// Our _events object forwards to bookmarksObserver.
var self = this;
this._events = {
addListener: function(aEvent, aListener) {
addListener: function bookmarkevents_al(aEvent, aListener) {
Utilities.bookmarksObserver.addListener(self._id, aEvent, aListener);
},
removeListener: function(aEvent, aListener) {
removeListener: function bookmarkevents_rl(aEvent, aListener) {
Utilities.bookmarksObserver.removeListener(self._id, aEvent, aListener);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
// For our onItemMoved listener, which updates this._parent.
@ -489,13 +491,13 @@ Bookmark.prototype = {
Utilities.bookmarks.removeItem(this._id);
},
onBeginUpdateBatch : function() {},
onEndUpdateBatch : function() {},
onItemAdded : function(aId, aFolder, aIndex, aItemType, aURI) {},
onBeforeItemRemoved : function(aId) {},
onItemVisited: function(aId, aVisitID, aTime) {},
onItemRemoved : function(aId, aFolder, aIndex) {},
onItemChanged : function(aId, aProperty, aIsAnnotationProperty, aValue) {},
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
onItemAdded: function () {},
onBeforeItemRemoved: function () {},
onItemVisited: function () {},
onItemRemoved: function () {},
onItemChanged: function () {},
onItemMoved: function(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
if (aId == this._id) {
@ -503,9 +505,9 @@ Bookmark.prototype = {
}
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBookmark,
Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIBookmark,
Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
};
@ -535,7 +537,7 @@ function BookmarkFolder(aId, aParent) {
var self = this;
this._events = {
addListener: function(aEvent, aListener) {
addListener: function bmfevents_al(aEvent, aListener) {
if (self._parent) {
if (/child$/.test(aEvent)) {
Utilities.bookmarksObserver.addFolderListener(self._id, aEvent, aListener);
@ -548,7 +550,7 @@ function BookmarkFolder(aId, aParent) {
Utilities.bookmarksObserver.addRootListener(aEvent, aListener);
}
},
removeListener: function(aEvent, aListener) {
removeListener: function bmfevents_rl(aEvent, aListener) {
if (self._parent) {
if (/child$/.test(aEvent)) {
Utilities.bookmarksObserver.removeFolderListener(self._id, aEvent, aListener);
@ -561,7 +563,7 @@ function BookmarkFolder(aId, aParent) {
Utilities.bookmarksObserver.removeRootListener(aEvent, aListener);
}
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
// For our onItemMoved listener, which updates this._parent.
@ -640,45 +642,45 @@ BookmarkFolder.prototype = {
return items;
},
addBookmark : function bmf_addbm(aTitle, aUri) {
addBookmark: function bmf_addbm(aTitle, aUri) {
var newBookmarkID = Utilities.bookmarks.insertBookmark(this._id, aUri, Utilities.bookmarks.DEFAULT_INDEX, aTitle);
var newBookmark = new Bookmark(newBookmarkID, this, "bookmark");
return newBookmark;
},
addSeparator : function bmf_addsep() {
addSeparator: function bmf_addsep() {
var newBookmarkID = Utilities.bookmarks.insertSeparator(this._id, Utilities.bookmarks.DEFAULT_INDEX);
var newBookmark = new Bookmark(newBookmarkID, this, "separator");
return newBookmark;
},
addFolder : function bmf_addfolder(aTitle) {
addFolder: function bmf_addfolder(aTitle) {
var newFolderID = Utilities.bookmarks.createFolder(this._id, aTitle, Utilities.bookmarks.DEFAULT_INDEX);
var newFolder = new BookmarkFolder(newFolderID, this);
return newFolder;
},
remove : function bmf_remove() {
remove: function bmf_remove() {
Utilities.bookmarks.removeItem(this._id);
},
// observer
onBeginUpdateBatch : function() {},
onEndUpdateBatch : function() {},
onItemAdded : function(aId, aFolder, aIndex, aItemType, aURI) {},
onBeforeItemRemoved : function(aId) {},
onItemRemoved : function(aId, aFolder, aIndex) {},
onItemChanged : function(aId, aProperty, aIsAnnotationProperty, aValue) {},
onBeginUpdateBatch: function () {},
onEndUpdateBatch : function () {},
onItemAdded : function () {},
onBeforeItemRemoved : function () {},
onItemRemoved : function () {},
onItemChanged : function () {},
onItemMoved: function(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
onItemMoved: function bf_onItemMoved(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
if (this._id == aId) {
this._parent = new BookmarkFolder(aNewParent, Utilities.bookmarks.getFolderIdForItem(aNewParent));
}
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBookmarkFolder,
Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIBookmarkFolder,
Ci.nsINavBookmarksObserver,
Ci.nsISupportsWeakReference])
};
//=================================================
@ -715,7 +717,7 @@ BookmarkRoots.prototype = {
return this._unfiled;
},
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBookmarkRoots])
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIBookmarkRoots])
};
@ -749,14 +751,14 @@ function Application() {
// Application implementation
Application.prototype = {
// for nsIClassInfo + XPCOMUtils
classID: APPLICATION_CID,
classID: APPLICATION_CID,
// redefine the default factory for XPCOMUtils
_xpcom_factory: ApplicationFactory,
// for nsISupports
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIApplication, Ci.extIApplication,
Ci.nsIObserver, Ci.nsISupportsWeakReference]),
QueryInterface: XPCOMUtils.generateQI([Ci.fuelIApplication, Ci.extIApplication,
Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// for nsIClassInfo
classInfo: XPCOMUtils.generateCI({classID: APPLICATION_CID,

View File

@ -9,17 +9,17 @@ Components.utils.import("resource://gre/modules/AddonManager.jsm");
// Console constructor
function Console() {
this._console = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
.getService(Ci.nsIConsoleService);
}
//=================================================
// Console implementation
Console.prototype = {
log : function cs_log(aMsg) {
log: function cs_log(aMsg) {
this._console.logStringMessage(aMsg);
},
open : function cs_open() {
open: function cs_open() {
var wMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
var console = wMediator.getMostRecentWindow("global:console");
@ -34,7 +34,7 @@ Console.prototype = {
}
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIConsole])
QueryInterface: XPCOMUtils.generateQI([Ci.extIConsole])
};
@ -48,7 +48,7 @@ function EventItem(aType, aData) {
//=================================================
// EventItem implementation
EventItem.prototype = {
_cancel : false,
_cancel: false,
get type() {
return this._type;
@ -58,11 +58,11 @@ EventItem.prototype = {
return this._data;
},
preventDefault : function ei_pd() {
preventDefault: function ei_pd() {
this._cancel = true;
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEventItem])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEventItem])
};
@ -76,7 +76,7 @@ function Events(notifier) {
//=================================================
// Events implementation
Events.prototype = {
addListener : function evts_al(aEvent, aListener) {
addListener: function evts_al(aEvent, aListener) {
function hasFilter(element) {
return element.event == aEvent && element.listener == aListener;
}
@ -94,7 +94,7 @@ Events.prototype = {
}
},
removeListener : function evts_rl(aEvent, aListener) {
removeListener: function evts_rl(aEvent, aListener) {
function hasFilter(element) {
return (element.event != aEvent) || (element.listener != aListener);
}
@ -102,7 +102,7 @@ Events.prototype = {
this._listeners = this._listeners.filter(hasFilter);
},
dispatch : function evts_dispatch(aEvent, aEventItem) {
dispatch: function evts_dispatch(aEvent, aEventItem) {
var eventItem = new EventItem(aEvent, aEventItem);
this._listeners.forEach(function(key){
@ -116,7 +116,7 @@ Events.prototype = {
return !eventItem._cancel;
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
//=================================================
@ -139,7 +139,7 @@ PreferenceObserver.prototype = {
* @param aListener the function to call back when the event fires. This
* function will receive an EventData argument.
*/
addListener: function(aPrefs, aDomain, aEvent, aListener) {
addListener: function po_al(aPrefs, aDomain, aEvent, aListener) {
var root = aPrefs.root;
if (!this._observersDict[root]) {
this._observersDict[root] = {};
@ -149,7 +149,7 @@ PreferenceObserver.prototype = {
if (!observer) {
observer = {
events: new Events(),
observe: function(aSubject, aTopic, aData) {
observe: function po_observer_obs(aSubject, aTopic, aData) {
this.events.dispatch("change", aData);
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
@ -170,7 +170,7 @@ PreferenceObserver.prototype = {
*
* This function's parameters are identical to addListener's.
*/
removeListener: function(aPrefs, aDomain, aEvent, aListener) {
removeListener: function po_rl(aPrefs, aDomain, aEvent, aListener) {
var root = aPrefs.root;
if (!this._observersDict[root] ||
!this._observersDict[root][aDomain]) {
@ -209,13 +209,13 @@ function PreferenceBranch(aBranch) {
let prefs = this._prefs;
this._events = {
addListener: function(aEvent, aListener) {
addListener: function pb_al(aEvent, aListener) {
gPreferenceObserver.addListener(prefs, "", aEvent, aListener);
},
removeListener: function(aEvent, aListener) {
removeListener: function pb_rl(aEvent, aListener) {
gPreferenceObserver.removeListener(prefs, "", aEvent, aListener);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
}
@ -240,7 +240,7 @@ PreferenceBranch.prototype = {
// type: Boolean, Number, String (getPrefType)
// locked: true, false (prefIsLocked)
// modified: true, false (prefHasUserValue)
find : function prefs_find(aOptions) {
find: function prefs_find(aOptions) {
var retVal = [];
var items = this._prefs.getChildList("");
@ -251,15 +251,15 @@ PreferenceBranch.prototype = {
return retVal;
},
has : function prefs_has(aName) {
has: function prefs_has(aName) {
return (this._prefs.getPrefType(aName) != Ci.nsIPrefBranch.PREF_INVALID);
},
get : function prefs_get(aName) {
get: function prefs_get(aName) {
return this.has(aName) ? new Preference(aName, this) : null;
},
getValue : function prefs_gv(aName, aValue) {
getValue: function prefs_gv(aName, aValue) {
var type = this._prefs.getPrefType(aName);
switch (type) {
@ -277,7 +277,7 @@ PreferenceBranch.prototype = {
return aValue;
},
setValue : function prefs_sv(aName, aValue) {
setValue: function prefs_sv(aName, aValue) {
var type = aValue != null ? aValue.constructor.name : "";
switch (type) {
@ -298,11 +298,11 @@ PreferenceBranch.prototype = {
}
},
reset : function prefs_reset() {
reset: function prefs_reset() {
this._prefs.resetBranch("");
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIPreferenceBranch])
QueryInterface: XPCOMUtils.generateQI([Ci.extIPreferenceBranch])
};
@ -314,13 +314,13 @@ function Preference(aName, aBranch) {
var self = this;
this._events = {
addListener: function(aEvent, aListener) {
addListener: function pref_al(aEvent, aListener) {
gPreferenceObserver.addListener(self._branch._prefs, self._name, aEvent, aListener);
},
removeListener: function(aEvent, aListener) {
removeListener: function pref_rl(aEvent, aListener) {
gPreferenceObserver.removeListener(self._branch._prefs, self._name, aEvent, aListener);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
}
@ -378,11 +378,11 @@ Preference.prototype = {
return this._events;
},
reset : function pref_reset() {
reset: function pref_reset() {
this.branch._prefs.clearUserPref(this.name);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIPreference])
QueryInterface: XPCOMUtils.generateQI([Ci.extIPreference])
};
@ -400,16 +400,16 @@ SessionStorage.prototype = {
return this._events;
},
has : function ss_has(aName) {
has: function ss_has(aName) {
return this._storage.hasOwnProperty(aName);
},
set : function ss_set(aName, aValue) {
set: function ss_set(aName, aValue) {
this._storage[aName] = aValue;
this._events.dispatch("change", aName);
},
get : function ss_get(aName, aDefaultValue) {
get: function ss_get(aName, aDefaultValue) {
return this.has(aName) ? this._storage[aName] : aDefaultValue;
},
@ -432,27 +432,27 @@ function ExtensionObserver() {
//=================================================
// ExtensionObserver implementation (internal class)
ExtensionObserver.prototype = {
onDisabling: function(addon, needsRestart) {
onDisabling: function eo_onDisabling(addon, needsRestart) {
this._dispatchEvent(addon.id, "disable");
},
onEnabling: function(addon, needsRestart) {
onEnabling: function eo_onEnabling(addon, needsRestart) {
this._dispatchEvent(addon.id, "enable");
},
onUninstalling: function(addon, needsRestart) {
onUninstalling: function eo_onUninstalling(addon, needsRestart) {
this._dispatchEvent(addon.id, "uninstall");
},
onOperationCancelled: function(addon) {
onOperationCancelled: function eo_onOperationCancelled(addon) {
this._dispatchEvent(addon.id, "cancel");
},
onInstallEnded: function(install, addon) {
onInstallEnded: function eo_onInstallEnded(install, addon) {
this._dispatchEvent(addon.id, "upgrade");
},
addListener: function(aId, aEvent, aListener) {
addListener: function eo_al(aId, aEvent, aListener) {
var events = this._eventsDict[aId];
if (!events) {
events = new Events();
@ -461,7 +461,7 @@ ExtensionObserver.prototype = {
events.addListener(aEvent, aListener);
},
removeListener: function(aId, aEvent, aListener) {
removeListener: function eo_rl(aId, aEvent, aListener) {
var events = this._eventsDict[aId];
if (!events) {
return;
@ -472,7 +472,7 @@ ExtensionObserver.prototype = {
}
},
_dispatchEvent: function(aId, aEvent) {
_dispatchEvent: function eo_dispatchEvent(aId, aEvent) {
var events = this._eventsDict[aId];
if (events) {
events.dispatch(aEvent, aId);
@ -490,13 +490,13 @@ function Extension(aItem) {
let id = this.id;
this._events = {
addListener: function(aEvent, aListener) {
addListener: function ext_events_al(aEvent, aListener) {
gExtensionObserver.addListener(id, aEvent, aListener);
},
removeListener: function(aEvent, aListener) {
removeListener: function ext_events_rl(aEvent, aListener) {
gExtensionObserver.addListener(id, aEvent, aListener);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIEvents])
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
};
var installPref = "install-event-fired";
@ -541,7 +541,7 @@ Extension.prototype = {
return this._events;
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIExtension])
QueryInterface: XPCOMUtils.generateQI([Ci.extIExtension])
};
@ -550,7 +550,7 @@ Extension.prototype = {
function Extensions(addons) {
this._cache = {};
addons.forEach(function(addon) {
addons.forEach(function (addon) {
this._cache[addon.id] = new Extension(addon);
}, this);
}
@ -568,19 +568,19 @@ Extensions.prototype = {
// version: "1.0.1"
// minVersion: "1.0"
// maxVersion: "2.0"
find : function exts_find(aOptions) {
find: function exts_find(aOptions) {
return [e for each (e in this._cache)];
},
has : function exts_has(aId) {
has: function exts_has(aId) {
return aId in this._cache;
},
get : function exts_get(aId) {
get: function exts_get(aId) {
return this.has(aId) ? this._cache[aId] : null;
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIExtensions])
QueryInterface: XPCOMUtils.generateQI([Ci.extIExtensions])
};
//=================================================
@ -647,24 +647,24 @@ extApplication.prototype = {
get console() {
let console = new Console();
this.__defineGetter__("console", function() console);
this.__defineGetter__("console", function () console);
return this.console;
},
get storage() {
let storage = new SessionStorage();
this.__defineGetter__("storage", function() storage);
this.__defineGetter__("storage", function () storage);
return this.storage;
},
get prefs() {
let prefs = new PreferenceBranch("");
this.__defineGetter__("prefs", function() prefs);
this.__defineGetter__("prefs", function () prefs);
return this.prefs;
},
getExtensions: function(callback) {
AddonManager.getAddonsByTypes(["extension"], function(addons) {
AddonManager.getAddonsByTypes(["extension"], function (addons) {
callback.callback(new Extensions(addons));
});
},
@ -687,7 +687,7 @@ extApplication.prototype = {
}
let events = new Events(registerCheck);
this.__defineGetter__("events", function() events);
this.__defineGetter__("events", function () events);
return this.events;
},
@ -715,5 +715,5 @@ extApplication.prototype = {
Components.interfaces.nsIAppStartup.eRestart);
},
QueryInterface : XPCOMUtils.generateQI([Ci.extIApplication, Ci.nsISupportsWeakReference])
QueryInterface: XPCOMUtils.generateQI([Ci.extIApplication, Ci.nsISupportsWeakReference])
};