Bug 1059102 - Part 2: rename msg[name] to message. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 27 Aug 2014 16:31:06 +0800
changeset 223782 e1b969fa5921a9c3bd73842569be676e6c128e58
parent 223781 5ce43c763281abfdc4b524c2802ab0fb0a92c8b7
child 223783 8365f90a9cecdb490374a54be7ee0ca126a462e7
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
bugs1059102
milestone34.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 1059102 - Part 2: rename msg[name] to message. r=dimi From 31016145026b17657dc8d2e22f2953b35204b0fc Mon Sep 17 00:00:00 2001 --- dom/nfc/gonk/Nfc.js | 110 ++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 55 deletions(-)
dom/nfc/gonk/Nfc.js
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -108,72 +108,72 @@ XPCOMUtils.defineLazyGetter(this, "gMess
 
       Services.obs.removeObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN);
       this._unregisterMessageListeners();
     },
 
     _registerMessageListeners: function _registerMessageListeners() {
       ppmm.addMessageListener("child-process-shutdown", this);
 
-      for (let msgname of NFC_IPC_MSG_NAMES) {
-        ppmm.addMessageListener(msgname, this);
+      for (let message of NFC_IPC_MSG_NAMES) {
+        ppmm.addMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_READ_PERM_MSG_NAMES) {
-        ppmm.addMessageListener(msgname, this);
+      for (let message of NFC_IPC_READ_PERM_MSG_NAMES) {
+        ppmm.addMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_WRITE_PERM_MSG_NAMES) {
-        ppmm.addMessageListener(msgname, this);
+      for (let message of NFC_IPC_WRITE_PERM_MSG_NAMES) {
+        ppmm.addMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_MANAGER_PERM_MSG_NAMES) {
-        ppmm.addMessageListener(msgname, this);
+      for (let message of NFC_IPC_MANAGER_PERM_MSG_NAMES) {
+        ppmm.addMessageListener(message, this);
       }
     },
 
     _unregisterMessageListeners: function _unregisterMessageListeners() {
       ppmm.removeMessageListener("child-process-shutdown", this);
 
-      for (let msgname of NFC_IPC_MSG_NAMES) {
-        ppmm.removeMessageListener(msgname, this);
+      for (let message of NFC_IPC_MSG_NAMES) {
+        ppmm.removeMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_READ_PERM_MSG_NAMES) {
-        ppmm.removeMessageListener(msgname, this);
+      for (let message of NFC_IPC_READ_PERM_MSG_NAMES) {
+        ppmm.removeMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_WRITE_PERM_MSG_NAMES) {
-        ppmm.removeMessageListener(msgname, this);
+      for (let message of NFC_IPC_WRITE_PERM_MSG_NAMES) {
+        ppmm.removeMessageListener(message, this);
       }
 
-      for (let msgname of NFC_IPC_MANAGER_PERM_MSG_NAMES) {
-        ppmm.removeMessageListener(msgname, this);
+      for (let message of NFC_IPC_MANAGER_PERM_MSG_NAMES) {
+        ppmm.removeMessageListener(message, this);
       }
 
       ppmm = null;
     },
 
-    registerPeerReadyTarget: function registerPeerReadyTarget(msg) {
-      let appInfo = msg.json;
+    registerPeerReadyTarget: function registerPeerReadyTarget(message) {
+      let appInfo = message.json;
       let targets = this.peerTargetsMap;
       let targetInfo = targets[appInfo.appId];
       // If the application Id is already registered
       if (targetInfo) {
         return;
       }
 
       // Target not registered yet! Add to the target map
-      let newTargetInfo = { target : msg.target,
+      let newTargetInfo = { target : message.target,
                             isPeerReadyCalled: false };
       targets[appInfo.appId] = newTargetInfo;
     },
 
-    unregisterPeerReadyTarget: function unregisterPeerReadyTarget(msg) {
-      let appInfo = msg.json;
+    unregisterPeerReadyTarget: function unregisterPeerReadyTarget(message) {
+      let appInfo = message.json;
       let targets = this.peerTargetsMap;
       let targetInfo = targets[appInfo.appId];
       if (targetInfo) {
         // Remove the target from the list of registered targets
         delete targets[appInfo.appId]
       }
     },
 
@@ -201,119 +201,119 @@ XPCOMUtils.defineLazyGetter(this, "gMess
     notifyPeerEvent: function notifyPeerEvent(appId, event, sessionToken) {
       let targetInfo = this.peerTargetsMap[appId];
       targetInfo.target.sendAsyncMessage("NFC:PeerEvent", {
         event: event,
         sessionToken: sessionToken
       });
     },
 
-    checkP2PRegistration: function checkP2PRegistration(msg) {
+    checkP2PRegistration: function checkP2PRegistration(message) {
       // Check if the session and application id yeild a valid registered
       // target.  It should have registered for NFC_PEER_EVENT_READY
       let isValid = !!this.nfc.sessionTokenMap[this.nfc._currentSessionId] &&
-                    this.isPeerReadyTarget(msg.json.appId);
+                    this.isPeerReadyTarget(message.json.appId);
       // Remember the current AppId if registered.
-      this.currentPeerAppId = (isValid) ? msg.json.appId : null;
+      this.currentPeerAppId = (isValid) ? message.json.appId : null;
 
-      let respMsg = { requestId: msg.json.requestId };
+      let respMsg = { requestId: message.json.requestId };
       if(!isValid) {
         respMsg.errorMsg = this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_P2P_REG_INVALID);
       }
       // Notify the content process immediately of the status
-      msg.target.sendAsyncMessage(msg.name + "Response", respMsg);
+      message.target.sendAsyncMessage(message.name + "Response", respMsg);
     },
 
     onPeerLost: function onPeerLost(sessionToken) {
       let appId = this.currentPeerAppId;
       // For peerlost, the message is delievered to the target which
       // registered onpeerready and onpeerready has been called before.
       if (this.isPeerReadyTarget(appId) && this.isPeerReadyCalled(appId)) {
         this.notifyPeerEvent(appId, NFC.NFC_PEER_EVENT_LOST, sessionToken);
         this.currentPeerAppId = null;
       }
     },
 
     /**
      * nsIMessageListener interface methods.
      */
 
-    receiveMessage: function receiveMessage(msg) {
-      debug("Received '" + JSON.stringify(msg) + "' message from content process");
-      if (msg.name == "child-process-shutdown") {
-        this.removePeerTarget(msg.target);
+    receiveMessage: function receiveMessage(message) {
+      debug("Received '" + JSON.stringify(message) + "' message from content process");
+      if (message.name == "child-process-shutdown") {
+        this.removePeerTarget(message.target);
         return null;
       }
 
-      if (NFC_IPC_MSG_NAMES.indexOf(msg.name) != -1) {
+      if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1) {
         // Do nothing.
-      } else if (NFC_IPC_READ_PERM_MSG_NAMES.indexOf(msg.name) != -1) {
-        if (!msg.target.assertPermission("nfc-read")) {
-          debug("Nfc message " + msg.name +
+      } else if (NFC_IPC_READ_PERM_MSG_NAMES.indexOf(message.name) != -1) {
+        if (!message.target.assertPermission("nfc-read")) {
+          debug("Nfc message " + message.name +
                 " from a content process with no 'nfc-read' privileges.");
           return null;
         }
-      } else if (NFC_IPC_WRITE_PERM_MSG_NAMES.indexOf(msg.name) != -1) {
-        if (!msg.target.assertPermission("nfc-write")) {
-          debug("Nfc Peer message  " + msg.name +
+      } else if (NFC_IPC_WRITE_PERM_MSG_NAMES.indexOf(message.name) != -1) {
+        if (!message.target.assertPermission("nfc-write")) {
+          debug("Nfc Peer message  " + message.name +
                 " from a content process with no 'nfc-write' privileges.");
           return null;
         }
-      } else if (NFC_IPC_MANAGER_PERM_MSG_NAMES.indexOf(msg.name) != -1) {
-        if (!msg.target.assertPermission("nfc-manager")) {
+      } else if (NFC_IPC_MANAGER_PERM_MSG_NAMES.indexOf(message.name) != -1) {
+        if (!message.target.assertPermission("nfc-manager")) {
           debug("NFC message " + message.name +
                 " from a content process with no 'nfc-manager' privileges.");
           return null;
         }
       } else {
-        debug("Ignoring unknown message type: " + msg.name);
+        debug("Ignoring unknown message type: " + message.name);
         return null;
       }
 
-      switch (msg.name) {
+      switch (message.name) {
         case "NFC:CheckSessionToken":
-          if (msg.json.sessionToken !== this.nfc.sessionTokenMap[this.nfc._currentSessionId]) {
-            debug("Received invalid Session Token: " + msg.json.sessionToken +
+          if (message.json.sessionToken !== this.nfc.sessionTokenMap[this.nfc._currentSessionId]) {
+            debug("Received invalid Session Token: " + message.json.sessionToken +
                   ", current SessionToken: " + this.nfc.sessionTokenMap[this.nfc._currentSessionId]);
             return NFC.NFC_ERROR_BAD_SESSION_ID;
           }
           return NFC.NFC_SUCCESS;
         case "NFC:RegisterPeerReadyTarget":
-          this.registerPeerReadyTarget(msg);
+          this.registerPeerReadyTarget(message);
           return null;
         case "NFC:UnregisterPeerReadyTarget":
-          this.unregisterPeerReadyTarget(msg);
+          this.unregisterPeerReadyTarget(message);
           return null;
         case "NFC:CheckP2PRegistration":
-          this.checkP2PRegistration(msg);
+          this.checkP2PRegistration(message);
           return null;
         case "NFC:NotifyUserAcceptedP2P":
           // Notify the 'NFC_PEER_EVENT_READY' since user has acknowledged
-          if (!this.isPeerReadyTarget(msg.json.appId)) {
-            debug("Application ID : " + msg.json.appId + " is not a registered PeerReadytarget");
+          if (!this.isPeerReadyTarget(message.json.appId)) {
+            debug("Application ID : " + message.json.appId + " is not a registered PeerReadytarget");
             return null;
           }
 
-          let targetInfo = this.peerTargetsMap[msg.json.appId];
+          let targetInfo = this.peerTargetsMap[message.json.appId];
           targetInfo.IsPeerReadyCalled = true;
           let sessionToken = this.nfc.sessionTokenMap[this.nfc._currentSessionId];
-          this.notifyPeerEvent(msg.json.appId, NFC.NFC_PEER_EVENT_READY, sessionToken);
+          this.notifyPeerEvent(message.json.appId, NFC.NFC_PEER_EVENT_READY, sessionToken);
           return null;
         case "NFC:NotifySendFileStatus":
           // Upon receiving the status of sendFile operation, send the response
           // to appropriate content process.
-          msg.json.type = "NotifySendFileStatus";
-          if (msg.json.status !== NFC.NFC_SUCCESS) {
-            msg.json.errorMsg =
+          message.json.type = "NotifySendFileStatus";
+          if (message.json.status !== NFC.NFC_SUCCESS) {
+            message.json.errorMsg =
               this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
           }
-          this.nfc.sendNfcResponse(msg.json);
+          this.nfc.sendNfcResponse(message.json);
           return null;
         default:
-          return this.nfc.receiveMessage(msg);
+          return this.nfc.receiveMessage(message);
       }
     },
 
     /**
      * nsIObserver interface methods.
      */
 
     observe: function observe(subject, topic, data) {