Bug 1165841 - Part 3: remove _rfState and init from NfcContentHelper. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 20 May 2015 17:10:17 +0800
changeset 266173 79714779c2aeacee8e57fec92ab3f67fb121f0d8
parent 266172 37e4520a3d14ae403b421f5c794c397c606c83fa
child 266174 863ea6c9461e84c8ed3f7e1c33866c9b6ab04a6e
push id2231
push usermichael.l.comella@gmail.com
push dateFri, 22 May 2015 20:04:59 +0000
reviewersdimi
bugs1165841
milestone41.0a1
Bug 1165841 - Part 3: remove _rfState and init from NfcContentHelper. r=dimi
dom/nfc/NfcContentHelper.js
dom/nfc/nsINfcContentHelper.idl
dom/nfc/nsNfc.js
--- a/dom/nfc/NfcContentHelper.js
+++ b/dom/nfc/NfcContentHelper.js
@@ -85,26 +85,20 @@ NfcContentHelper.prototype = {
   classInfo: XPCOMUtils.generateCI({
     classID:          NFCCONTENTHELPER_CID,
     classDescription: "NfcContentHelper",
     interfaces:       [Ci.nsINfcContentHelper,
                        Ci.nsINfcBrowserAPI]
   }),
 
   _requestMap: null,
-  _rfState: null,
   eventListener: null,
 
-  init: function init(aWindow) {
-    let info = cpmm.sendSyncMessage("NFC:QueryInfo")[0];
-    this._rfState = info.rfState;
-  },
-
   queryRFState: function queryRFState() {
-    return this._rfState;
+    return cpmm.sendSyncMessage("NFC:QueryInfo")[0].rfState;
   },
 
   setFocusApp: function setFocusApp(tabId, isFocus) {
     cpmm.sendAsyncMessage("NFC:SetFocusApp", {
       tabId: tabId,
       isFocus: isFocus
     });
   },
@@ -314,18 +308,17 @@ NfcContentHelper.prototype = {
                                               tagInfo,
                                               ndefInfo,
                                               result.records);
             break;
           case NFC.TAG_EVENT_LOST:
             this.eventListener.notifyTagLost(result.sessionToken);
             break;
           case NFC.RF_EVENT_STATE_CHANGED:
-            this._rfState = result.rfState;
-            this.eventListener.notifyRFStateChanged(this._rfState);
+            this.eventListener.notifyRFStateChanged(result.rfState);
             break;
           case NFC.FOCUS_CHANGED:
             this.eventListener.notifyFocusChanged(result.focus);
             break;
         }
         break;
     }
   },
--- a/dom/nfc/nsINfcContentHelper.idl
+++ b/dom/nfc/nsINfcContentHelper.idl
@@ -119,21 +119,19 @@ interface nsINfcRequestCallback : nsISup
 interface nsINfcBrowserAPI : nsISupports
 {
   const int32_t SYSTEM_APP_ID = -1;
 
   void setFocusApp(in uint64_t tabId,
                    in boolean isFocus);
 };
 
-[scriptable, uuid(080a84f1-f039-46ed-9dc6-f34ce3aa9638)]
+[scriptable, uuid(f098c114-b21f-43f5-9f53-0c22b4f194eb)]
 interface nsINfcContentHelper : nsISupports
 {
-  void init(in nsIDOMWindow window);
-
   /**
    * Read current NDEF data on the tag.
    *
    * @param sessionToken
    *        Current token
    *
    * @param callback
    *        Called when request is finished
@@ -201,17 +199,17 @@ interface nsINfcContentHelper : nsISuppo
    *
    */
   void transceive(in DOMString sessionToken,
                   in DOMString technology,
                   in nsIVariant command,
                   in nsINfcRequestCallback callback);
 
   /**
-   * Get current RF state.
+   * Get current RF state. This function will be blocking.
    */
   DOMString queryRFState();
 
   /**
    * Initiate send file operation.
    *
    * @param blob
    *        Raw data of the file to be sent. This object represents a file-like
--- a/dom/nfc/nsNfc.js
+++ b/dom/nfc/nsNfc.js
@@ -356,17 +356,16 @@ MozNFCImpl.prototype = {
     this.window = aWindow;
     this.defineEventHandlerGetterSetter("ontagfound");
     this.defineEventHandlerGetterSetter("ontaglost");
     this.defineEventHandlerGetterSetter("onpeerready");
     this.defineEventHandlerGetterSetter("onpeerfound");
     this.defineEventHandlerGetterSetter("onpeerlost");
 
     if (this._nfcContentHelper) {
-      this._nfcContentHelper.init(aWindow);
       this._tabId = this.getTabId(aWindow);
       this._nfcContentHelper.addEventListener(this, this._tabId);
       this._rfState = this._nfcContentHelper.queryRFState();
     }
   },
 
   getTabId: function getTabId(aWindow) {
     let tabId;