mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 793361 - Apps, SystemMessages: free message manager references for killed children. r=fabrice
This commit is contained in:
parent
f0a3f6136f
commit
f869e2715c
@ -187,8 +187,6 @@ WebappsRegistry.prototype = {
|
||||
|
||||
uninit: function() {
|
||||
this._mgmt = null;
|
||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||
["Webapps:Install:Return:OK"]);
|
||||
},
|
||||
|
||||
// mozIDOMApplicationRegistry2 implementation
|
||||
@ -484,9 +482,6 @@ WebappsApplication.prototype = {
|
||||
|
||||
uninit: function() {
|
||||
this._onprogress = null;
|
||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||
["Webapps:Uninstall:Return:OK", "Webapps:OfflineCache",
|
||||
"Webapps:PackageEvent"]);
|
||||
},
|
||||
|
||||
_fireEvent: function(aName, aHandler) {
|
||||
@ -649,8 +644,6 @@ WebappsApplicationMgmt.prototype = {
|
||||
uninit: function() {
|
||||
this._oninstall = null;
|
||||
this._onuninstall = null;
|
||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||
["Webapps:Install:Return:OK", "Webapps:Uninstall:Return:OK"]);
|
||||
},
|
||||
|
||||
applyDownload: function(aApp) {
|
||||
|
@ -159,9 +159,9 @@ let DOMApplicationRegistry = {
|
||||
"Webapps:Launch", "Webapps:GetAll",
|
||||
"Webapps:InstallPackage", "Webapps:GetBasePath",
|
||||
"Webapps:GetList", "Webapps:RegisterForMessages",
|
||||
"Webapps:UnregisterForMessages",
|
||||
"Webapps:CancelDownload", "Webapps:CheckForUpdate",
|
||||
"Webapps::Download", "Webapps::ApplyDownload"];
|
||||
"Webapps::Download", "Webapps::ApplyDownload",
|
||||
"child-process-shutdown"];
|
||||
|
||||
this.frameMessages = ["Webapps:ClearBrowserData"];
|
||||
|
||||
@ -512,17 +512,17 @@ let DOMApplicationRegistry = {
|
||||
}, this);
|
||||
},
|
||||
|
||||
removeMessageListener: function(aMsgNames, aMm) {
|
||||
aMsgNames.forEach(function (aMsgName) {
|
||||
if (!(aMsgName in this.children)) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeMessageListener: function(aMm) {
|
||||
for (let i = this.children.length - 1; i >= 0; i -= 1) {
|
||||
msg = this.children[i];
|
||||
|
||||
let index;
|
||||
if ((index = this.children[aMsgName].indexOf(aMm)) != -1) {
|
||||
this.children[aMsgName].splice(index, 1);
|
||||
if ((index = msg.indexOf(aMm)) != -1) {
|
||||
debug("Remove dead mm at index " + index);
|
||||
msg.splice(index, 1);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
@ -542,7 +542,7 @@ let DOMApplicationRegistry = {
|
||||
}
|
||||
}
|
||||
|
||||
let msg = aMessage.json;
|
||||
let msg = aMessage.data || {};
|
||||
let mm = aMessage.target;
|
||||
msg.mm = mm;
|
||||
|
||||
@ -585,9 +585,6 @@ let DOMApplicationRegistry = {
|
||||
case "Webapps:RegisterForMessages":
|
||||
this.addMessageListener(msg, mm);
|
||||
break;
|
||||
case "Webapps:UnregisterForMessages":
|
||||
this.removeMessageListener(msg, mm);
|
||||
break;
|
||||
case "Webapps:GetList":
|
||||
this.addMessageListener(["Webapps:AddApp", "Webapps:RemoveApp"], mm);
|
||||
return this.webapps;
|
||||
@ -610,6 +607,9 @@ let DOMApplicationRegistry = {
|
||||
this.onInitDone();
|
||||
}
|
||||
break;
|
||||
case "child-process-shutdown":
|
||||
this.removeMessageListener(mm);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -27,7 +27,7 @@ try {
|
||||
|
||||
const kMessages =["SystemMessageManager:GetPending",
|
||||
"SystemMessageManager:Register",
|
||||
"SystemMessageManager:Unregister"]
|
||||
"child-process-shutdown"]
|
||||
|
||||
function debug(aMsg) {
|
||||
//dump("-- SystemMessageInternal " + Date.now() + " : " + aMsg + "\n");
|
||||
@ -50,24 +50,12 @@ SystemMessageInternal.prototype = {
|
||||
sendMessage: function sendMessage(aType, aMessage, aPageURI, aManifestURI) {
|
||||
debug("Broadcasting " + aType + " " + JSON.stringify(aMessage));
|
||||
if (this._listeners[aManifestURI.spec]) {
|
||||
let i;
|
||||
let listener;
|
||||
for (i = this._listeners[aManifestURI.spec].length - 1; i >= 0; i -= 1) {
|
||||
listener = this._listeners[aManifestURI.spec][i];
|
||||
try {
|
||||
listener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
this._listeners[aManifestURI.spec].forEach(function sendMsg(aListener) {
|
||||
aListener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aManifestURI.spec })
|
||||
} catch (e) {
|
||||
// Remove once 777508 lands.
|
||||
let index;
|
||||
if ((index = this._listeners[aManifestURI.spec].indexOf(listener)) != -1) {
|
||||
this._listeners[aManifestURI.spec].splice(index, 1);
|
||||
dump("Remove dead MessageManager!\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
this._pages.forEach(function sendMess_openPage(aPage) {
|
||||
@ -87,23 +75,12 @@ SystemMessageInternal.prototype = {
|
||||
this._pages.forEach(function(aPage) {
|
||||
if (aPage.type == aType) {
|
||||
if (this._listeners[aPage.manifest]) {
|
||||
let i;
|
||||
for (i = this._listeners[aPage.manifest].length - 1; i >= 0; i -= 1) {
|
||||
let listener = this._listeners[aPage.manifest][i];
|
||||
try {
|
||||
listener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
this._listeners[aPage.manifest].forEach(function sendMsg(aListener) {
|
||||
aListener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aPage.manifest})
|
||||
} catch (e) {
|
||||
// Remove once 777508 lands.
|
||||
let index;
|
||||
if ((index = this._listeners[aPage.manifest].indexOf(listener)) != -1) {
|
||||
this._listeners[aPage.manifest].splice(index, 1);
|
||||
dump("Remove dead MessageManager!\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
this._processPage(aPage, aMessage);
|
||||
}
|
||||
@ -133,7 +110,7 @@ SystemMessageInternal.prototype = {
|
||||
this._listeners[manifest].push(aMessage.target);
|
||||
debug("listeners for " + manifest + " : " + this._listeners[manifest].length);
|
||||
break;
|
||||
case "SystemMessageManager:Unregister":
|
||||
case "child-process-shutdown":
|
||||
debug("Got Unregister from " + aMessage.target);
|
||||
let mm = aMessage.target;
|
||||
for (let manifest in this._listeners) {
|
||||
|
@ -143,7 +143,6 @@ SystemMessageManager.prototype = {
|
||||
},
|
||||
|
||||
uninit: function sysMessMgr_uninit() {
|
||||
cpmm.sendAsyncMessage("SystemMessageManager:Unregister", { });
|
||||
this._handlers = null;
|
||||
this._pendings = null;
|
||||
},
|
||||
|
@ -29,7 +29,7 @@ let SettingsChangeNotifier = {
|
||||
init: function() {
|
||||
debug("init");
|
||||
this.children = [];
|
||||
this._messages = ["Settings:Changed", "Settings:RegisterForMessages", "Settings:UnregisterForMessages"];
|
||||
this._messages = ["Settings:Changed", "Settings:RegisterForMessages", "child-process-shutdown"];
|
||||
this._messages.forEach((function(msgName) {
|
||||
ppmm.addMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
@ -68,24 +68,15 @@ let SettingsChangeNotifier = {
|
||||
},
|
||||
|
||||
broadcastMessage: function broadcastMessage(aMsgName, aContent) {
|
||||
let i;
|
||||
for (i = this.children.length - 1; i >= 0; i -= 1) {
|
||||
let msgMgr = this.children[i];
|
||||
try {
|
||||
debug("Broadast");
|
||||
this.children.forEach(function(msgMgr) {
|
||||
msgMgr.sendAsyncMessage(aMsgName, aContent);
|
||||
} catch (e) {
|
||||
let index;
|
||||
if ((index = this.children.indexOf(msgMgr)) != -1) {
|
||||
this.children.splice(index, 1);
|
||||
dump("Remove dead MessageManager!\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
debug("receiveMessage");
|
||||
let msg = aMessage.json;
|
||||
let msg = aMessage.data;
|
||||
let mm = aMessage.target;
|
||||
switch (aMessage.name) {
|
||||
case "Settings:Changed":
|
||||
@ -104,10 +95,11 @@ let SettingsChangeNotifier = {
|
||||
this.children.push(mm);
|
||||
}
|
||||
break;
|
||||
case "Settings:UnregisterForMessages":
|
||||
case "child-process-shutdown":
|
||||
debug("Unregister");
|
||||
let index;
|
||||
if ((index = this.children.indexOf(mm)) != -1) {
|
||||
debug("Unregister index: " + index);
|
||||
this.children.splice(index, 1);
|
||||
}
|
||||
break;
|
||||
|
@ -342,7 +342,6 @@ SettingsManager.prototype = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
debug("Topic: " + aTopic);
|
||||
if (aTopic == "inner-window-destroyed") {
|
||||
cpmm.sendAsyncMessage("Settings:UnregisterForMessages");
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == this.innerWindowID) {
|
||||
Services.obs.removeObserver(this, "inner-window-destroyed");
|
||||
|
Loading…
x
Reference in New Issue
Block a user