Bug 1140383: Add fast path for NFC:QueryInfo, r=allstars.chh
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 10 Mar 2015 13:51:57 +0100
changeset 232845 f0e9898a7604c31dbe630e8c79d8f3b1d0c82cc8
parent 232844 d5e5fcb29452dfc0f6b4de9b352f9334477fdc4d
child 232846 3db05b03389cc5f18cf58405e087efaabc0820b8
push id28393
push userkwierso@gmail.com
push dateTue, 10 Mar 2015 22:45:23 +0000
treeherdermozilla-central@a9aff724afc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars.chh
bugs1140383
milestone39.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 1140383: Add fast path for NFC:QueryInfo, r=allstars.chh Messages of type NFC:QueryInfo return local RF state. We don't need the NFC Service, so we can return early.
dom/nfc/gonk/Nfc.js
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -658,19 +658,26 @@ Nfc.prototype = {
      */
     gSystemMessenger.broadcastMessage("nfc-hci-event-transaction", message);
   },
 
   /**
    * Process a message from the gMessageManager.
    */
   receiveMessage: function receiveMessage(message) {
-      if (["NFC:ChangeRFState",
-           "NFC:SendFile",
-           "NFC:QueryInfo"].indexOf(message.name) == -1) {
+    // Return early if we don't need the NFC Service.
+    switch (message.name) {
+      case "NFC:QueryInfo":
+        return {rfState: this.rfState};
+      default:
+        break;
+    }
+
+    if (["NFC:ChangeRFState",
+         "NFC:SendFile"].indexOf(message.name) == -1) {
       // Update the current sessionId before sending to the NFC service.
       message.data.sessionId = SessionHelper.getId(message.data.sessionToken);
     }
 
     switch (message.name) {
       case "NFC:ChangeRFState":
         this.sendToNfcService(NfcRequestType.CHANGE_RF_STATE, message.data);
         break;
@@ -699,18 +706,16 @@ Nfc.prototype = {
 
         // Notify system app to initiate BT send file operation
         let sysMsg = new NfcSendFileSysMsg(message.data.requestId,
                                            message.data.sessionToken,
                                            message.data.blob);
         gSystemMessenger.broadcastMessage("nfc-manager-send-file",
                                           sysMsg);
         break;
-      case "NFC:QueryInfo":
-        return {rfState: this.rfState};
       default:
         debug("UnSupported : Message Name " + message.name);
         return null;
     }
     this.targetsByRequestId[message.data.requestId] = message.target;
 
     return null;
   },