Bug 856495 - Push notifications - Catch network manager undefined. r=nsm
authorDoug Turner <dougt@dougt.org>
Mon, 22 Apr 2013 11:43:31 -0400
changeset 140432 f511f109d4e9f6ffd9f5e6c465e936dfa2409efc
parent 140431 675cf08dc15415871de164ba7ace3052993d0e35
child 140433 26ab26b299a5c2e00ebcbb82362fc2120ae757de
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm
bugs856495
milestone23.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 856495 - Push notifications - Catch network manager undefined. r=nsm
dom/push/src/PushService.js
--- a/dom/push/src/PushService.js
+++ b/dom/push/src/PushService.js
@@ -1290,36 +1290,32 @@ PushService.prototype = {
 
   /**
    * Get mobile network information to decide if the client is capable of being woken
    * up by UDP (which currently just means having an mcc and mnc along with an
    * IP).
    */
   _getNetworkState: function() {
     debug("getNetworkState()");
-
-    var networkManager = Cc["@mozilla.org/network/manager;1"]
-                           .getService(Ci.nsINetworkManager);
-    if (networkManager.active &&
-        networkManager.active.type ==
-                      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
-      debug("Running on mobile data");
-      var mcp = Cc["@mozilla.org/ril/content-helper;1"]
-                  .getService(Ci.nsIMobileConnectionProvider);
-      if (mcp.iccInfo) {
-        return {
-          mcc: mcp.iccInfo.mcc,
-          mnc: mcp.iccInfo.mnc,
-          ip: networkManager.active.ip
+    try {
+      var nm = Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
+      if (nm.active && nm.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
+        var mcp = Cc["@mozilla.org/ril/content-helper;1"].getService(Ci.nsIMobileConnectionProvider);
+        if (mcp.iccInfo) {
+          debug("Running on mobile data");
+          return {
+            mcc: mcp.iccInfo.mcc,
+            mnc: mcp.iccInfo.mnc,
+            ip:  nm.active.ip
+          }
         }
       }
-    }
-    else {
-      debug("Running on wifi");
-    }
+    } catch (e) {}
+
+    debug("Running on wifi");
 
     return {
       mcc: 0,
       mnc: 0,
       ip: undefined
     };
   }
 }