Bug 936359 - Honor the DEBUG flag in RilContentHelper.js. r=hsinyi, a=bajaj
authorVicamo Yang <vyang@mozilla.com>
Mon, 11 Nov 2013 10:42:55 +0800
changeset 166453 1ac3265c0795a91c398f3c63e3012a7a745b3c70
parent 166452 7c876e9d50cba0a2c33195fc7169d3e21cae47af
child 166454 7f09e42dbbbd27aa486854856d197963d774c46e
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi, bajaj
bugs936359
milestone27.0a2
Bug 936359 - Honor the DEBUG flag in RilContentHelper.js. r=hsinyi, a=bajaj
dom/system/gonk/RILContentHelper.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -561,17 +561,17 @@ RILContentHelper.prototype = {
     // changed messages.
     this.getRilContext = function getRilContext() {
       return this.rilContext;
     };
 
     let rilContext =
       cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: 0})[0];
     if (!rilContext) {
-      debug("Received null rilContext from chrome process.");
+      if (DEBUG) debug("Received null rilContext from chrome process.");
       return;
     }
     this.rilContext.cardState = rilContext.cardState;
     this.rilContext.networkSelectionMode = rilContext.networkSelectionMode;
     this.updateIccInfo(rilContext.iccInfo);
     this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
     this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
 
@@ -854,17 +854,17 @@ RILContentHelper.prototype = {
         lockType: lockType,
         requestId: requestId
       }
     });
     return request;
   },
 
   sendMMI: function sendMMI(window, mmi) {
-    debug("Sending MMI " + mmi);
+    if (DEBUG) debug("Sending MMI " + mmi);
     if (!window) {
       throw Components.Exception("Can't get window object",
                                  Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     // We need to save the global window to get the proper MMIError
     // constructor once we get the reply from the parent process.
@@ -876,17 +876,17 @@ RILContentHelper.prototype = {
         mmi: mmi,
         requestId: requestId
       }
     });
     return request;
   },
 
   cancelMMI: function cancelMMI(window) {
-    debug("Cancel MMI");
+    if (DEBUG) debug("Cancel MMI");
     if (!window) {
       throw Components.Exception("Can't get window object",
                                  Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     cpmm.sendAsyncMessage("RIL:CancelMMI", {
       clientId: 0,
@@ -1377,47 +1377,47 @@ RILContentHelper.prototype = {
     let index = listeners.indexOf(listener);
     if (index != -1) {
       listeners.splice(index, 1);
       if (DEBUG) debug("Unregistered listener: " + listener);
     }
   },
 
   registerMobileConnectionMsg: function registerMobileConnectionMsg(listener) {
-    debug("Registering for mobile connection related messages");
+    if (DEBUG) debug("Registering for mobile connection related messages");
     this.registerListener("_mobileConnectionListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
   },
 
   unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(listener) {
     this.unregisterListener("_mobileConnectionListeners", listener);
   },
 
   registerVoicemailMsg: function registerVoicemailMsg(listener) {
-    debug("Registering for voicemail-related messages");
+    if (DEBUG) debug("Registering for voicemail-related messages");
     this.registerListener("_voicemailListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
   },
 
   unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
     this.unregisterListener("_voicemailListeners", listener);
   },
 
   registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) {
-    debug("Registering for Cell Broadcast related messages");
+    if (DEBUG) debug("Registering for Cell Broadcast related messages");
     this.registerListener("_cellBroadcastListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg");
   },
 
   unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) {
     this.unregisterListener("_cellBroadcastListeners", listener);
   },
 
   registerIccMsg: function registerIccMsg(listener) {
-    debug("Registering for ICC related messages");
+    if (DEBUG) debug("Registering for ICC related messages");
     this.registerListener("_iccListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
   },
 
   unregisterIccMsg: function unregisterIccMsg(listener) {
     this.unregisterListener("_iccListeners", listener);
   },
 
@@ -1500,17 +1500,19 @@ RILContentHelper.prototype = {
       return;
     }
 
     Services.DOMRequest.fireDetailedError(request, detailedError);
   },
 
   receiveMessage: function receiveMessage(msg) {
     let request;
-    debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
+    if (DEBUG) {
+      debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
+    }
 
     let data = msg.json.data;
     switch (msg.name) {
       case "RIL:CardStateChanged":
         if (this.rilContext.cardState != data.cardState) {
           this.rilContext.cardState = data.cardState;
           this._deliverEvent("_iccListeners",
                              "notifyCardStateChanged",
@@ -1697,19 +1699,21 @@ RILContentHelper.prototype = {
     if (errorMsg) {
       this.fireRequestError(requestId, errorMsg);
     } else {
       this.fireRequestSuccess(requestId, result);
     }
   },
 
   handleGetAvailableNetworks: function handleGetAvailableNetworks(message) {
-    debug("handleGetAvailableNetworks: " + JSON.stringify(message));
+    if (DEBUG) debug("handleGetAvailableNetworks: " + JSON.stringify(message));
     if (message.errorMsg) {
-      debug("Received error from getAvailableNetworks: " + message.errorMsg);
+      if (DEBUG) {
+        debug("Received error from getAvailableNetworks: " + message.errorMsg);
+      }
       this.fireRequestError(message.requestId, message.errorMsg);
       return;
     }
 
     let networks = message.networks;
     for (let i = 0; i < networks.length; i++) {
       let network = networks[i];
       let info = new MobileNetworkInfo();
@@ -1855,17 +1859,17 @@ RILContentHelper.prototype = {
     if (!message.success) {
       Services.DOMRequest.fireError(request, message.errorMsg);
       return;
     }
     Services.DOMRequest.fireSuccess(request, null);
   },
 
   handleSendCancelMMI: function handleSendCancelMMI(message) {
-    debug("handleSendCancelMMI " + JSON.stringify(message));
+    if (DEBUG) debug("handleSendCancelMMI " + JSON.stringify(message));
     let request = this.takeRequest(message.requestId);
     let requestWindow = this._windowsMap[message.requestId];
     delete this._windowsMap[message.requestId];
     if (!request) {
       return;
     }
 
     let success = message.success;
@@ -1919,17 +1923,17 @@ RILContentHelper.prototype = {
       }
       let handler = listener[name];
       if (typeof handler != "function") {
         throw new Error("No handler for " + name);
       }
       try {
         handler.apply(listener, args);
       } catch (e) {
-        debug("listener for " + name + " threw an exception: " + e);
+        if (DEBUG) debug("listener for " + name + " threw an exception: " + e);
       }
     }
   },
 
   /**
    * Helper for guarding us again invalid reason values for call forwarding.
    */
   _isValidCFReason: function _isValidCFReason(reason) {