Bug 1059102 - Part 3: s/json/data/g. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 27 Aug 2014 16:32:22 +0800
changeset 202157 8365f90a9cecdb490374a54be7ee0ca126a462e7
parent 202156 e1b969fa5921a9c3bd73842569be676e6c128e58
child 202158 d5a96b73d651084675a0d6a980388d145d68b83d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdimi
bugs1059102
milestone34.0a1
Bug 1059102 - Part 3: s/json/data/g. r=dimi
dom/nfc/gonk/Nfc.js
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -148,32 +148,32 @@ XPCOMUtils.defineLazyGetter(this, "gMess
       for (let message of NFC_IPC_MANAGER_PERM_MSG_NAMES) {
         ppmm.removeMessageListener(message, this);
       }
 
       ppmm = null;
     },
 
     registerPeerReadyTarget: function registerPeerReadyTarget(message) {
-      let appInfo = message.json;
+      let appInfo = message.data;
       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 : message.target,
                             isPeerReadyCalled: false };
       targets[appInfo.appId] = newTargetInfo;
     },
 
     unregisterPeerReadyTarget: function unregisterPeerReadyTarget(message) {
-      let appInfo = message.json;
+      let appInfo = message.data;
       let targets = this.peerTargetsMap;
       let targetInfo = targets[appInfo.appId];
       if (targetInfo) {
         // Remove the target from the list of registered targets
         delete targets[appInfo.appId]
       }
     },
 
@@ -205,21 +205,21 @@ XPCOMUtils.defineLazyGetter(this, "gMess
         sessionToken: sessionToken
       });
     },
 
     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(message.json.appId);
+                    this.isPeerReadyTarget(message.data.appId);
       // Remember the current AppId if registered.
-      this.currentPeerAppId = (isValid) ? message.json.appId : null;
+      this.currentPeerAppId = (isValid) ? message.data.appId : null;
 
-      let respMsg = { requestId: message.json.requestId };
+      let respMsg = { requestId: message.data.requestId };
       if(!isValid) {
         respMsg.errorMsg = this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_P2P_REG_INVALID);
       }
       // Notify the content process immediately of the status
       message.target.sendAsyncMessage(message.name + "Response", respMsg);
     },
 
     onPeerLost: function onPeerLost(sessionToken) {
@@ -265,52 +265,52 @@ XPCOMUtils.defineLazyGetter(this, "gMess
         }
       } else {
         debug("Ignoring unknown message type: " + message.name);
         return null;
       }
 
       switch (message.name) {
         case "NFC:CheckSessionToken":
-          if (message.json.sessionToken !== this.nfc.sessionTokenMap[this.nfc._currentSessionId]) {
-            debug("Received invalid Session Token: " + message.json.sessionToken +
+          if (message.data.sessionToken !== this.nfc.sessionTokenMap[this.nfc._currentSessionId]) {
+            debug("Received invalid Session Token: " + message.data.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(message);
           return null;
         case "NFC:UnregisterPeerReadyTarget":
           this.unregisterPeerReadyTarget(message);
           return null;
         case "NFC:CheckP2PRegistration":
           this.checkP2PRegistration(message);
           return null;
         case "NFC:NotifyUserAcceptedP2P":
           // Notify the 'NFC_PEER_EVENT_READY' since user has acknowledged
-          if (!this.isPeerReadyTarget(message.json.appId)) {
-            debug("Application ID : " + message.json.appId + " is not a registered PeerReadytarget");
+          if (!this.isPeerReadyTarget(message.data.appId)) {
+            debug("Application ID : " + message.data.appId + " is not a registered PeerReadytarget");
             return null;
           }
 
-          let targetInfo = this.peerTargetsMap[message.json.appId];
+          let targetInfo = this.peerTargetsMap[message.data.appId];
           targetInfo.IsPeerReadyCalled = true;
           let sessionToken = this.nfc.sessionTokenMap[this.nfc._currentSessionId];
-          this.notifyPeerEvent(message.json.appId, NFC.NFC_PEER_EVENT_READY, sessionToken);
+          this.notifyPeerEvent(message.data.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.
-          message.json.type = "NotifySendFileStatus";
-          if (message.json.status !== NFC.NFC_SUCCESS) {
-            message.json.errorMsg =
+          message.data.type = "NotifySendFileStatus";
+          if (message.data.status !== NFC.NFC_SUCCESS) {
+            message.data.errorMsg =
               this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
           }
-          this.nfc.sendNfcResponse(message.json);
+          this.nfc.sendNfcResponse(message.data);
           return null;
         default:
           return this.nfc.receiveMessage(message);
       }
     },
 
     /**
      * nsIObserver interface methods.
@@ -392,18 +392,18 @@ Nfc.prototype = {
    *        An nsIMessageListener's message parameter.
    */
   sendNfcErrorResponse: function sendNfcErrorResponse(message, errorCode) {
     if (!message.target) {
       return;
     }
 
     let nfcMsgType = message.name + "Response";
-    message.json.errorMsg = this.getErrorMessage(errorCode);
-    message.target.sendAsyncMessage(nfcMsgType, message.json);
+    message.data.errorMsg = this.getErrorMessage(errorCode);
+    message.target.sendAsyncMessage(nfcMsgType, message.data);
   },
 
   getErrorMessage: function getErrorMessage(errorCode) {
     return NFC.NFC_ERROR_MSG[errorCode] ||
            NFC.NFC_ERROR_MSG[NFC.NFC_GECKO_ERROR_GENERIC_FAILURE];
   },
 
   /**
@@ -513,75 +513,75 @@ Nfc.prototype = {
     if (!isPowerAPI) {
       if (this.powerLevel != NFC.NFC_POWER_LEVEL_ENABLED) {
         debug("NFC is not enabled. current powerLevel:" + this.powerLevel);
         this.sendNfcErrorResponse(message, NFC.NFC_GECKO_ERROR_NOT_ENABLED);
         return null;
       }
 
       // Update the current sessionId before sending to the NFC service.
-      message.json.sessionId = this._currentSessionId;
+      message.data.sessionId = this._currentSessionId;
     }
 
     // Sanity check on sessionId
     let sessionToken = this.sessionTokenMap[this._currentSessionId];
-    if (message.json.sessionToken && (message.json.sessionToken !== sessionToken)) {
-      debug("Invalid Session Token: " + message.json.sessionToken +
+    if (message.data.sessionToken && (message.data.sessionToken !== sessionToken)) {
+      debug("Invalid Session Token: " + message.data.sessionToken +
             " Expected Session Token: " + sessionToken);
       this.sendNfcErrorResponse(message, NFC.NFC_ERROR_BAD_SESSION_ID);
       return null;
     }
 
     switch (message.name) {
       case "NFC:StartPoll":
         this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_ENABLED,
-                        requestId: message.json.requestId});
+                        requestId: message.data.requestId});
         break;
       case "NFC:StopPoll":
         this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_LOW,
-                        requestId: message.json.requestId});
+                        requestId: message.data.requestId});
         break;
       case "NFC:PowerOff":
         this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_DISABLED,
-                        requestId: message.json.requestId});
+                        requestId: message.data.requestId});
         break;
       case "NFC:GetDetailsNDEF":
-        this.sendToNfcService("getDetailsNDEF", message.json);
+        this.sendToNfcService("getDetailsNDEF", message.data);
         break;
       case "NFC:ReadNDEF":
-        this.sendToNfcService("readNDEF", message.json);
+        this.sendToNfcService("readNDEF", message.data);
         break;
       case "NFC:WriteNDEF":
-        this.sendToNfcService("writeNDEF", message.json);
+        this.sendToNfcService("writeNDEF", message.data);
         break;
       case "NFC:MakeReadOnlyNDEF":
-        this.sendToNfcService("makeReadOnlyNDEF", message.json);
+        this.sendToNfcService("makeReadOnlyNDEF", message.data);
         break;
       case "NFC:Connect":
-        this.sendToNfcService("connect", message.json);
+        this.sendToNfcService("connect", message.data);
         break;
       case "NFC:Close":
-        this.sendToNfcService("close", message.json);
+        this.sendToNfcService("close", message.data);
         break;
       case "NFC:SendFile":
         // Chrome process is the arbitrator / mediator between
         // system app (content process) that issued nfc 'sendFile' operation
         // and system app that handles the system message :
         // 'nfc-manager-send-file'. System app subsequently handover's
         // the data to alternate carrier's (BT / WiFi) 'sendFile' interface.
 
         // Notify system app to initiate BT send file operation
         gSystemMessenger.broadcastMessage("nfc-manager-send-file",
-                                           message.json);
+                                           message.data);
         break;
       default:
         debug("UnSupported : Message Name " + message.name);
         return null;
     }
-    this.targetsByRequestId[message.json.requestId] = message.target;
+    this.targetsByRequestId[message.data.requestId] = message.target;
 
     return null;
   },
 
   /**
    * nsIObserver interface methods.
    */
   observe: function(subject, topic, data) {