Bug 781620 - Bridge the DOM webapps registry with nsIPrincipal::GetStatus() - Part 4 : leak fix [r=jlebar]

This commit is contained in:
Fabrice Desré 2012-08-29 07:31:10 -07:00
Родитель 8086b57d65
Коммит 60b394963d
1 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -14,6 +14,7 @@ const Ci = Components.interfaces;
let EXPORTED_SYMBOLS = ["DOMApplicationRegistry"];
Cu.import("resource://gre/modules/AppsUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function debug(s) {
//dump("-*- AppsServiceChild.jsm: " + s + "\n");
@ -32,6 +33,16 @@ let DOMApplicationRegistry = {
// We need to prime the cache with the list of apps.
// XXX shoud we do this async and block callers if it's not yet there?
this.webapps = this.cpmm.sendSyncMessage("Webapps:GetList", { })[0];
Services.obs.addObserver(this, "xpcom-shutdown", false);
},
observe: function(aSubject, aTopic, aData) {
// cpmm.addMessageListener causes the DOMApplicationRegistry object to live
// forever if we don't clean up properly.
this.webapps = null;
["Webapps:AddApp", "Webapps:RemoveApp"].forEach((function(aMsgName) {
this.cpmm.removeMessageListener(aMsgName, this);
}).bind(this));
},
receiveMessage: function receiveMessage(aMessage) {