Bug 909786 - Use incremental id as the hash key of |controlCallbacks|. r=vchang
authorHenry Chang <hchang@mozilla.com>
Tue, 27 Aug 2013 23:38:10 +0800
changeset 146162 687e3a6868bf803ab7efefb0fa807a7821a446ad
parent 146161 bc0aba8051440881f3aba0ac59cdc549b929b136
child 146163 9edc229b7d09c689d870ca6be7a8a3dd655d6088
push id25243
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 19:52:36 +0000
treeherdermozilla-central@9edc229b7d09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang
bugs909786
milestone26.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 909786 - Use incremental id as the hash key of |controlCallbacks|. r=vchang
dom/system/gonk/NetworkManager.js
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -451,19 +451,20 @@ NetworkManager.prototype = {
       } else {
         callback.wifiOperationModeResult(null);
       }
     });
   },
 
   // Helpers
 
+  idgen: 0,
   controlMessage: function controlMessage(params, callback) {
     if (callback) {
-      let id = callback.name;
+      let id = this.idgen++;
       params.id = id;
       this.controlCallbacks[id] = callback;
     }
     this.worker.postMessage(params);
   },
 
   handleWorkerMessage: function handleWorkerMessage(e) {
     debug("NetworkManager received message from worker: " + JSON.stringify(e.data));
@@ -471,16 +472,17 @@ NetworkManager.prototype = {
     let id = response.id;
     if (id == 'broadcast') {
       Services.obs.notifyObservers(null, response.topic, response.reason);
       return;
     }
     let callback = this.controlCallbacks[id];
     if (callback) {
       callback.call(this, response);
+      delete this.controlCallbacks[id];
     }
   },
 
   setExtraHostRoute: function setExtraHostRoute(network) {
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
       debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route");
       let mmsHosts = this.resolveHostname(
                        [Services.prefs.getCharPref("ril.mms.mmsproxy"),