Bug 1085296 - B2G NFC: enable debug when either flag is enabled or settings is enabled. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Mon, 24 Nov 2014 10:10:32 +0800
changeset 241700 6cc8e0d10b40ef5cc1b2efc3d292d9d56f1301cc
parent 241699 81276aaa1101c232d058784574b642a1c392d48c
child 241701 83fe5533439cd789aab9dc3f3e88b348e1805604
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs1085296
milestone36.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 1085296 - B2G NFC: enable debug when either flag is enabled or settings is enabled. r=dimi
dom/nfc/NfcContentHelper.js
dom/nfc/gonk/Nfc.js
dom/nfc/gonk/nfc_consts.js
--- a/dom/nfc/NfcContentHelper.js
+++ b/dom/nfc/NfcContentHelper.js
@@ -32,17 +32,17 @@ XPCOMUtils.defineLazyGetter(this, "NFC",
 Cu.import("resource://gre/modules/systemlibs.js");
 const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
 
 // set to true to in nfc_consts.js to see debug messages
 let DEBUG = NFC.DEBUG_CONTENT_HELPER;
 
 let debug;
 function updateDebug() {
-  if (DEBUG) {
+  if (DEBUG || NFC.DEBUG_CONTENT_HELPER) {
     debug = function (s) {
       dump("-*- NfcContentHelper: " + s + "\n");
     };
   } else {
     debug = function (s) {};
   }
 };
 updateDebug();
@@ -94,17 +94,17 @@ NfcContentHelper.prototype = {
   init: function init(aWindow) {
     if (aWindow == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     this._window = aWindow;
     this.initDOMRequestHelper(this._window, NFC_IPC_MSG_NAMES);
 
-    if (this._window.navigator.mozSettings) {
+    if (!NFC.DEBUG_CONTENT_HELPER && this._window.navigator.mozSettings) {
       let lock = this._window.navigator.mozSettings.createLock();
       var nfcDebug = lock.get(NFC.SETTING_NFC_DEBUG);
       nfcDebug.onsuccess = function _nfcDebug() {
         DEBUG = nfcDebug.result[NFC.SETTING_NFC_DEBUG];
         updateDebug();
       };
     }
   },
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -35,17 +35,17 @@ XPCOMUtils.defineLazyGetter(this, "NFC",
 Cu.import("resource://gre/modules/systemlibs.js");
 const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
 
 // set to true in nfc_consts.js to see debug messages
 let DEBUG = NFC.DEBUG_NFC;
 
 let debug;
 function updateDebug() {
-  if (DEBUG) {
+  if (DEBUG || NFC.DEBUG_NFC) {
     debug = function (s) {
       dump("-*- Nfc: " + s + "\n");
     };
   } else {
     debug = function (s) {};
   }
 };
 updateDebug();
@@ -103,20 +103,22 @@ XPCOMUtils.defineLazyGetter(this, "gMess
     // Manage registered Peer Targets
     peerTargets: {},
 
     eventListeners: [],
 
     init: function init(nfc) {
       this.nfc = nfc;
 
-      let lock = gSettingsService.createLock();
-      lock.get(NFC.SETTING_NFC_DEBUG, this.nfc);
+      if (!NFC.DEBUG_NFC) {
+        let lock = gSettingsService.createLock();
+        lock.get(NFC.SETTING_NFC_DEBUG, this.nfc);
+        Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
+      }
 
-      Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
       Services.obs.addObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN, false);
       this._registerMessageListeners();
     },
 
     _shutdown: function _shutdown() {
       this.nfc.shutdown();
       this.nfc = null;
 
--- a/dom/nfc/gonk/nfc_consts.js
+++ b/dom/nfc/gonk/nfc_consts.js
@@ -14,18 +14,18 @@
  */
 
 /* Copyright © 2013, Deutsche Telekom, Inc. */
 
 // Set to true to debug all NFC layers
 this.DEBUG_ALL = false;
 
 // Set individually to debug specific layers
-this.DEBUG_CONTENT_HELPER = false || DEBUG_ALL;
-this.DEBUG_NFC = false || DEBUG_ALL;
+this.DEBUG_CONTENT_HELPER = DEBUG_ALL || false;
+this.DEBUG_NFC = DEBUG_ALL || false;
 
 // Gecko specific error codes
 this.NFC_GECKO_SUCCESS = 0;
 this.NFC_GECKO_ERROR_GENERIC_FAILURE = 1;
 this.NFC_GECKO_ERROR_P2P_REG_INVALID = 2;
 this.NFC_GECKO_ERROR_NOT_ENABLED = 3;
 this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 4;
 this.NFC_GECKO_ERROR_BAD_SESSION_TOKEN = 5;