Bug 1065128 - Make Settings API use dom-window-destroyed for shutdown; r=bent a=bbajaj
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 19 Sep 2014 10:25:36 -0700
changeset 224951 bfb75367ae2490e75f282bb51623a8c49e606534
parent 224950 63382fe8225ee0144df0a649403ce46fb9b6c9a3
child 224952 6484b4d22e3340b19fede9426ebcad8b62da44ed
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, bbajaj
bugs1065128
milestone34.0a2
Bug 1065128 - Make Settings API use dom-window-destroyed for shutdown; r=bent a=bbajaj
dom/settings/SettingsManager.js
--- a/dom/settings/SettingsManager.js
+++ b/dom/settings/SettingsManager.js
@@ -346,26 +346,25 @@ SettingsManager.prototype = {
   },
 
   init: function(aWindow) {
     if (DEBUG) debug("SettingsManager init");
     mrm.registerStrongReporter(this);
     cpmm.addMessageListener("Settings:Change:Return:OK", this);
     this._window = aWindow;
     this._principal = this._window.document.nodePrincipal;
-    Services.obs.addObserver(this, "inner-window-destroyed", false);
+    Services.obs.addObserver(this, "dom-window-destroyed", false);
     let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
     this.innerWindowID = util.currentInnerWindowID;
   },
 
   observe: function(aSubject, aTopic, aData) {
-    if (aTopic == "inner-window-destroyed") {
-      let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
-      if (wId == this.innerWindowID) {
-        if (DEBUG) debug("Topic: " + aTopic);
+    if (aTopic == "dom-window-destroyed") {
+      let window = aSubject.QueryInterface(Ci.nsIDOMWindow);
+      if (window == this._window) {
         this.cleanup();
       }
     }
   },
 
   collectReports: function(aCallback, aData, aAnonymize) {
     for (let topic in this._callbacks) {
       let length = this._callbacks[topic].length;
@@ -386,17 +385,17 @@ SettingsManager.prototype = {
                          Ci.nsIMemoryReporter.UNITS_COUNT,
                          this._callbacks[topic].length,
                          "The number of settings observers for this topic.",
                          aData);
     }
   },
 
   cleanup: function() {
-    Services.obs.removeObserver(this, "inner-window-destroyed");
+    Services.obs.removeObserver(this, "dom-window-destroyed");
     cpmm.removeMessageListener("Settings:Change:Return:OK", this);
     mrm.unregisterStrongReporter(this);
     // At this point, the window is dying, so there's nothing left
     // that we could do with our lock. Go ahead and run finalize on
     // it to make sure changes are commited.
     for (let i = 0; i < this._locks.length; ++i) {
       if (DEBUG) debug("Lock alive at destroy, finalizing: " + this._locks[i]);
       cpmm.sendAsyncMessage("Settings:Finalize",