Bug 988129 - Correct the chaotic naming styles in system message codes (part 4, alignment). r=fabrice

This commit is contained in:
Gene Lian 2014-03-31 16:04:42 +08:00
parent ef988a9700
commit 7482d09827
2 changed files with 39 additions and 17 deletions

View File

@ -28,7 +28,8 @@ XPCOMUtils.defineLazyServiceGetter(this, "powerManagerService",
// Limit the number of pending messages for a given page.
let kMaxPendingMessages;
try {
kMaxPendingMessages = Services.prefs.getIntPref("dom.messages.maxPendingMessages");
kMaxPendingMessages =
Services.prefs.getIntPref("dom.messages.maxPendingMessages");
} catch(e) {
// getIntPref throws when the pref is not set.
kMaxPendingMessages = 5;
@ -94,7 +95,8 @@ SystemMessageInternal.prototype = {
_getMessageConfigurator: function(aType) {
debug("_getMessageConfigurator for type: " + aType);
if (this._configurators[aType] === undefined) {
let contractID = "@mozilla.org/dom/system-messages/configurator/" + aType + ";1";
let contractID =
"@mozilla.org/dom/system-messages/configurator/" + aType + ";1";
if (contractID in Cc) {
debug(contractID + " is registered, creating an instance");
this._configurators[aType] =
@ -297,7 +299,10 @@ SystemMessageInternal.prototype = {
return true;
},
_removeTargetFromListener: function(aTarget, aManifestURL, aRemoveListener, aPageURL) {
_removeTargetFromListener: function(aTarget,
aManifestURL,
aRemoveListener,
aPageURL) {
let targets = this._listeners[aManifestURL];
if (!targets) {
return false;
@ -365,7 +370,8 @@ SystemMessageInternal.prototype = {
winCounts[pageURL] = 1;
this._listeners[msg.manifestURL] = [{ target: aMessage.target,
winCounts: winCounts }];
} else if ((index = this._findTargetIndex(targets, aMessage.target)) === -1) {
} else if ((index = this._findTargetIndex(targets,
aMessage.target)) === -1) {
let winCounts = {};
winCounts[pageURL] = 1;
targets.push({ target: aMessage.target,
@ -379,7 +385,8 @@ SystemMessageInternal.prototype = {
}
}
debug("listeners for " + msg.manifestURL + " innerWinID " + msg.innerWindowID);
debug("listeners for " + msg.manifestURL +
" innerWinID " + msg.innerWindowID);
break;
}
case "child-process-shutdown":
@ -387,7 +394,10 @@ SystemMessageInternal.prototype = {
debug("Got child-process-shutdown from " + aMessage.target);
for (let manifestURL in this._listeners) {
// See if any processes in this manifest URL have this target.
if (this._removeTargetFromListener(aMessage.target, manifestURL, true, null)) {
if (this._removeTargetFromListener(aMessage.target,
manifestURL,
true,
null)) {
break;
}
}
@ -395,8 +405,12 @@ SystemMessageInternal.prototype = {
}
case "SystemMessageManager:Unregister":
{
debug("Got Unregister from " + aMessage.target + "innerWinID " + msg.innerWindowID);
this._removeTargetFromListener(aMessage.target, msg.manifestURL, false, msg.pageURL);
debug("Got Unregister from " + aMessage.target +
" innerWinID " + msg.innerWindowID);
this._removeTargetFromListener(aMessage.target,
msg.manifestURL,
false,
msg.pageURL);
break;
}
case "SystemMessageManager:GetPendingMessages":
@ -467,7 +481,8 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:HandleMessagesDone":
{
debug("received SystemMessageManager:HandleMessagesDone " + msg.type +
" with " + msg.handledCount + " for " + msg.pageURL + " @ " + msg.manifestURL);
" with " + msg.handledCount + " for " + msg.pageURL +
" @ " + msg.manifestURL);
// A page has finished handling some of its system messages, so we try
// to release the CPU wake lock we acquired on behalf of that page.
@ -546,7 +561,9 @@ SystemMessageInternal.prototype = {
onlyShowApp: onlyShowApp,
showApp: showApp };
debug("Asking to open " + JSON.stringify(page));
Services.obs.notifyObservers(this, "system-messages-open-app", JSON.stringify(page));
Services.obs.notifyObservers(this,
"system-messages-open-app",
JSON.stringify(page));
},
_isPageMatched: function(aPage, aType, aPageURL, aManifestURL) {
@ -635,7 +652,8 @@ SystemMessageInternal.prototype = {
classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal, Ci.nsIObserver])
QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal,
Ci.nsIObserver])
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageInternal]);

View File

@ -194,14 +194,17 @@ SystemMessageManager.prototype = {
receiveMessage: function(aMessage) {
let msg = aMessage.data;
debug("receiveMessage " + aMessage.name + " for [" + msg.type + "] " +
"with manifest URL = " + msg.manifestURL + " and page URL = " + msg.pageURL);
"with manifest URL = " + msg.manifestURL +
" and page URL = " + msg.pageURL);
// Multiple windows can share the same target (process), the content
// window needs to check if the manifest/page URL is matched. Only
// *one* window should handle the system message.
if (msg.manifestURL !== this._manifestURL || msg.pageURL !== this._pageURL) {
if (msg.manifestURL !== this._manifestURL ||
msg.pageURL !== this._pageURL) {
debug("This page shouldn't handle the messages because its " +
"manifest URL = " + this._manifestURL + " and page URL = " + this._pageURL);
"manifest URL = " + this._manifestURL +
" and page URL = " + this._pageURL);
return;
}
@ -247,7 +250,8 @@ SystemMessageManager.prototype = {
// nsIDOMGlobalPropertyInitializer implementation.
init: function(aWindow) {
debug("init");
this.initDOMRequestHelper(aWindow, ["SystemMessageManager:Message",
this.initDOMRequestHelper(aWindow,
["SystemMessageManager:Message",
"SystemMessageManager:GetPendingMessages:Return"]);
let principal = aWindow.document.nodePrincipal;