Bug 1055960 - Part 2: Add removeTarget. r=dimi, a=bajaj
authorYoshi Huang <allstars.chh@mozilla.com>
Mon, 01 Sep 2014 13:59:12 +0800
changeset 224654 16c12e16d4becf79e7e006ebd446f933b16fcbe6
parent 224653 34b9f8cfa6aaade33db29965c5b69a046bd35deb
child 224655 885be57b98b755bf2516bf401e9c643cefa16987
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)
reviewersdimi, bajaj
bugs1055960
milestone34.0a2
Bug 1055960 - Part 2: Add removeTarget. r=dimi, a=bajaj
dom/nfc/gonk/Nfc.js
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -230,16 +230,17 @@ XPCOMUtils.defineLazyGetter(this, "gMess
     /**
      * nsIMessageListener interface methods.
      */
 
     receiveMessage: function receiveMessage(message) {
       debug("Received '" + JSON.stringify(message) + "' message from content process");
       if (message.name == "child-process-shutdown") {
         this.removePeerTarget(message.target);
+        this.nfc.removeTarget(message.target);
         return null;
       }
 
       if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1) {
         // Do nothing.
       } else if (NFC_IPC_READ_PERM_MSG_NAMES.indexOf(message.name) != -1) {
         if (!message.target.assertPermission("nfc-read")) {
           debug("Nfc message " + message.name +
@@ -562,16 +563,24 @@ Nfc.prototype = {
         debug("UnSupported : Message Name " + message.name);
         return null;
     }
     this.targetsByRequestId[message.data.requestId] = message.target;
 
     return null;
   },
 
+  removeTarget: function removeTarget(target) {
+    Object.keys(this.targetsByRequestId).forEach((requestId) => {
+      if (this.targetsByRequestId[requestId] === target) {
+        delete this.targetsByRequestId[requestId];
+      }
+    });
+  },
+
   /**
    * nsIObserver interface methods.
    */
   observe: function(subject, topic, data) {
     if (topic != "profile-after-change") {
       debug("Should receive 'profile-after-change' only, received " + topic);
     }
   },