Bug 802823 - Early cleanup of message listeners in ActivityProxy.js [r=gwagner]
authorFabrice Desré <fabrice@mozilla.com>
Thu, 18 Oct 2012 15:30:57 -0700
changeset 110717 1167feab3ae545d1f006525c9fbc8bbabc1677f5
parent 110716 62627192e1563789da8b97907ffd342f4348f31d
child 110718 47a36175f4a5d47f91a7319536537c6e382e783b
push id23712
push useremorley@mozilla.com
push dateFri, 19 Oct 2012 14:23:49 +0000
treeherdermozilla-central@7fcac3016159 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs802823
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 802823 - Early cleanup of message listeners in ActivityProxy.js [r=gwagner]
dom/activities/src/ActivityProxy.js
--- a/dom/activities/src/ActivityProxy.js
+++ b/dom/activities/src/ActivityProxy.js
@@ -75,21 +75,26 @@ ActivityProxy.prototype = {
         Services.DOMRequest.fireSuccess(this.activity,
                                         ObjectWrapper.wrap(msg.result, this.window));
         break;
       case "Activity:FireError":
         debug("FireError");
         Services.DOMRequest.fireError(this.activity, msg.error);
         break;
     }
+    // We can only get one FireSuccess / FireError message, so cleanup as soon as possible.
+    this.cleanup();
   },
 
   cleanup: function actProxy_cleanup() {
     debug("cleanup");
-    cpmm.removeMessageListener("Activity:FireSuccess", this);
-    cpmm.removeMessageListener("Activity:FireError", this);
+    if (!this.cleanedUp) {
+      cpmm.removeMessageListener("Activity:FireSuccess", this);
+      cpmm.removeMessageListener("Activity:FireError", this);
+    }
+    this.cleanedUp = true;
   },
 
   classID: Components.ID("{ba9bd5cb-76a0-4ecf-a7b3-d2f7c43c5949}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIActivityProxy])
 }
 
 const NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityProxy]);