Bug 1167132 - Part 2: [NetworkManager] Move network information into a separate interface (NetworkManager). r=echen
authorJessica Jong <jjong@mozilla.com>
Wed, 29 Jul 2015 02:02:00 -0400
changeset 286944 c722ee4b5cc32ca7f7b6a2b72711fde62f0fbed8
parent 286943 d30bd2a5787226a5ce22c201cb5fa6ac13c8c4c2
child 286945 ed6a2c98608da9a0b0fac4a466d0c86848419de9
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1167132
milestone42.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 1167132 - Part 2: [NetworkManager] Move network information into a separate interface (NetworkManager). r=echen
dom/system/gonk/NetworkManager.js
dom/system/gonk/tests/marionette/head.js
dom/system/gonk/tests/marionette/test_network_active_changed.js
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -11,17 +11,17 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/systemlibs.js");
 Cu.import("resource://gre/modules/Promise.jsm");
 
 const NETWORKMANAGER_CONTRACTID = "@mozilla.org/network/manager;1";
 const NETWORKMANAGER_CID =
   Components.ID("{33901e46-33b8-11e1-9869-f46d04d25bcc}");
 
-const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
+const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
 
 XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
   return Cc["@mozilla.org/parentprocessmessagemanager;1"]
          .getService(Ci.nsIMessageBroadcaster);
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
@@ -80,52 +80,52 @@ updateDebug();
 
 function defineLazyRegExp(obj, name, pattern) {
   obj.__defineGetter__(name, function() {
     delete obj[name];
     return obj[name] = new RegExp(pattern);
   });
 }
 
-function NetworkInterface(aNetwork) {
+function ExtraNetworkInfo(aNetwork) {
   let ips = {};
   let prefixLengths = {};
-  aNetwork.getAddresses(ips, prefixLengths);
+  aNetwork.info.getAddresses(ips, prefixLengths);
 
-  this.state = aNetwork.state;
-  this.type = aNetwork.type;
-  this.name = aNetwork.name;
+  this.state = aNetwork.info.state;
+  this.type = aNetwork.info.type;
+  this.name = aNetwork.info.name;
   this.ips = ips.value;
   this.prefixLengths = prefixLengths.value;
-  this.gateways = aNetwork.getGateways();
-  this.dnses = aNetwork.getDnses();
+  this.gateways = aNetwork.info.getGateways();
+  this.dnses = aNetwork.info.getDnses();
   this.httpProxyHost = aNetwork.httpProxyHost;
   this.httpProxyPort = aNetwork.httpProxyPort;
 }
-NetworkInterface.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
-
+ExtraNetworkInfo.prototype = {
   getAddresses: function(aIps, aPrefixLengths) {
     aIps.value = this.ips.slice();
     aPrefixLengths.value = this.prefixLengths.slice();
 
     return this.ips.length;
   },
 
   getGateways: function(aCount) {
     if (aCount) {
       aCount.value = this.gateways.length;
     }
+
     return this.gateways.slice();
   },
 
   getDnses: function(aCount) {
     if (aCount) {
       aCount.value = this.dnses.length;
     }
+
     return this.dnses.slice();
   }
 };
 
 function NetworkInterfaceLinks()
 {
   this.resetLinks();
 }
@@ -227,21 +227,21 @@ NetworkManager.prototype = {
         let excludeMms = aMsg.json.excludeMms;
         let excludeSupl = aMsg.json.excludeSupl;
         let excludeIms = aMsg.json.excludeIms;
         let excludeDun = aMsg.json.excludeDun;
         let excludeFota = aMsg.json.excludeFota;
         let interfaces = [];
 
         for each (let i in this.networkInterfaces) {
-          if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
-              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
-              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS && excludeIms) ||
-              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN && excludeDun) ||
-              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA && excludeFota)) {
+          if ((i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
+              (i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
+              (i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS && excludeIms) ||
+              (i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN && excludeDun) ||
+              (i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA && excludeFota)) {
             continue;
           }
 
           let ips = {};
           let prefixLengths = {};
           i.getAddresses(ips, prefixLengths);
 
           interfaces.push({
@@ -256,44 +256,44 @@ NetworkManager.prototype = {
             httpProxyPort: i.httpProxyPort
           });
         }
         return interfaces;
       }
     }
   },
 
-  getNetworkId: function(network) {
+  getNetworkId: function(aNetworkInfo) {
     let id = "device";
     try {
-      if (network instanceof Ci.nsIRilNetworkInterface) {
-        let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
-        id = "ril" + rilNetwork.serviceId;
+      if (aNetworkInfo instanceof Ci.nsIRilNetworkInfo) {
+        let rilInfo = aNetworkInfo.QueryInterface(Ci.nsIRilNetworkInfo);
+        id = "ril" + rilInfo.serviceId;
       }
     } catch (e) {}
 
-    return id + "-" + network.type;
+    return id + "-" + aNetworkInfo.type;
   },
 
   // nsINetworkManager
 
   registerNetworkInterface: function(network) {
     if (!(network instanceof Ci.nsINetworkInterface)) {
       throw Components.Exception("Argument must be nsINetworkInterface.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
-    let networkId = this.getNetworkId(network);
+    let networkId = this.getNetworkId(network.info);
     if (networkId in this.networkInterfaces) {
       throw Components.Exception("Network with that type already registered!",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     this.networkInterfaces[networkId] = network;
     this.networkInterfaceLinks[networkId] = new NetworkInterfaceLinks();
 
-    Services.obs.notifyObservers(network, TOPIC_INTERFACE_REGISTERED, null);
+    Services.obs.notifyObservers(network.info, TOPIC_INTERFACE_REGISTERED, null);
     debug("Network '" + networkId + "' registered.");
   },
 
   _addSubnetRoutes: function(network) {
     let ips = {};
     let prefixLengths = {};
     let length = network.getAddresses(ips, prefixLengths);
     let promises = [];
@@ -311,201 +311,211 @@ NetworkManager.prototype = {
     return Promise.all(promises);
   },
 
   updateNetworkInterface: function(network) {
     if (!(network instanceof Ci.nsINetworkInterface)) {
       throw Components.Exception("Argument must be nsINetworkInterface.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
-    let networkId = this.getNetworkId(network);
+    let networkId = this.getNetworkId(network.info);
     if (!(networkId in this.networkInterfaces)) {
       throw Components.Exception("No network with that type registered.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
-    debug("Network " + network.type + "/" + network.name +
-          " changed state to " + network.state);
+    debug("Network " + network.info.type + "/" + network.info.name +
+          " changed state to " + network.info.state);
 
     // Keep a copy of network in case it is modified while we are updating.
-    let networkInterface = new NetworkInterface(network);
+    let extNetworkInfo = new ExtraNetworkInfo(network);
 
     // Note that since Lollipop we need to allocate and initialize
     // something through netd, so we add createNetwork/destroyNetwork
     // to deal with that explicitly.
 
-    switch (networkInterface.state) {
-      case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
+    switch (extNetworkInfo.state) {
+      case Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED:
 
-        this._createNetwork(networkInterface.name)
+        this._createNetwork(extNetworkInfo.name)
           // Remove pre-created default route and let setAndConfigureActive()
           // to set default route only on preferred network
-          .then(() => this._removeDefaultRoute(networkInterface))
+          .then(() => this._removeDefaultRoute(extNetworkInfo))
           // Set DNS server as early as possible to prevent from
           // premature domain name lookup.
-          .then(() => this._setDNS(networkInterface))
+          .then(() => this._setDNS(extNetworkInfo))
           .then(() => {
             // Add host route for data calls
-            if (!this.isNetworkTypeMobile(networkInterface.type)) {
+            if (!this.isNetworkTypeMobile(extNetworkInfo.type)) {
               return;
             }
 
             let currentInterfaceLinks = this.networkInterfaceLinks[networkId];
-            let newLinkRoutes = networkInterface.getDnses().concat(
-              networkInterface.httpProxyHost);
+            let newLinkRoutes = extNetworkInfo.getDnses().concat(
+              extNetworkInfo.httpProxyHost);
             // If gateways have changed, remove all old routes first.
-            return this._handleGateways(networkId, networkInterface.getGateways())
+            return this._handleGateways(networkId, extNetworkInfo.getGateways())
               .then(() => this._updateRoutes(currentInterfaceLinks.linkRoutes,
                                              newLinkRoutes,
-                                             networkInterface.getGateways(),
-                                             networkInterface.name))
+                                             extNetworkInfo.getGateways(),
+                                             extNetworkInfo.name))
               .then(() => currentInterfaceLinks.setLinks(newLinkRoutes,
-                                                         networkInterface.getGateways(),
-                                                         networkInterface.name));
+                                                         extNetworkInfo.getGateways(),
+                                                         extNetworkInfo.name));
           })
           .then(() => {
-            if (networkInterface.type !=
-                Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
+            if (extNetworkInfo.type !=
+                Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN) {
               return;
             }
             // Dun type is a special case where we add the default route to a
             // secondary table.
-            return this.setSecondaryDefaultRoute(networkInterface);
+            return this.setSecondaryDefaultRoute(extNetworkInfo);
           })
-          .then(() => this._addSubnetRoutes(networkInterface))
+          .then(() => this._addSubnetRoutes(extNetworkInfo))
           .then(() => this.setAndConfigureActive())
           .then(() => {
             // Update data connection when Wifi connected/disconnected
-            if (networkInterface.type ==
-                Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
+            if (extNetworkInfo.type ==
+                Ci.nsINetworkInfo.NETWORK_TYPE_WIFI && this.mRil) {
               for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
                 this.mRil.getRadioInterface(i).updateRILNetworkInterface();
               }
             }
 
             // Probing the public network accessibility after routing table is ready
             CaptivePortalDetectionHelper
-              .notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
+              .notify(CaptivePortalDetectionHelper.EVENT_CONNECT,
+                      this.activeNetworkInfo);
           })
           .then(() => {
             // Notify outer modules like MmsService to start the transaction after
             // the configuration of the network interface is done.
-            Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
-                                         this.convertConnectionType(network));
+            Services.obs.notifyObservers(network.info,
+                                         TOPIC_CONNECTION_STATE_CHANGED,
+                                         this.convertConnectionType(network.info));
           })
           .catch(aError => {
             debug("updateNetworkInterface error: " + aError);
           });
         break;
-      case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
+      case Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED:
         Promise.resolve()
           .then(() => {
-            if (!this.isNetworkTypeMobile(networkInterface.type)) {
+            if (!this.isNetworkTypeMobile(extNetworkInfo.type)) {
               return;
             }
             // Remove host route for data calls
             return this._cleanupAllHostRoutes(networkId);
           })
           .then(() => {
-            if (networkInterface.type !=
-                Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
+            if (extNetworkInfo.type !=
+                Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN) {
               return;
             }
             // Remove secondary default route for dun.
-            return this.removeSecondaryDefaultRoute(networkInterface);
+            return this.removeSecondaryDefaultRoute(extNetworkInfo);
           })
           .then(() => {
-            if (networkInterface.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
+            if (extNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
               // Remove routing table in /proc/net/route
-              return this._resetRoutingTable(networkInterface.name);
+              return this._resetRoutingTable(extNetworkInfo.name);
             }
-            if (networkInterface.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
-              return this._removeDefaultRoute(networkInterface)
+            if (extNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
+              return this._removeDefaultRoute(extNetworkInfo)
             }
           })
           .then(() => {
             // Clear http proxy on active network.
-            if (this.active && networkInterface.type == this.active.type) {
+            if (this.activeNetworkInfo &&
+                extNetworkInfo.type == this.activeNetworkInfo.type) {
               this.clearNetworkProxy();
             }
 
             // Abort ongoing captive portal detection on the wifi interface
             CaptivePortalDetectionHelper
-              .notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, networkInterface);
+              .notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, extNetworkInfo);
           })
           .then(() => this.setAndConfigureActive())
           .then(() => {
             // Update data connection when Wifi connected/disconnected
-            if (networkInterface.type ==
-                Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
+            if (extNetworkInfo.type ==
+                Ci.nsINetworkInfo.NETWORK_TYPE_WIFI && this.mRil) {
               for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
                 this.mRil.getRadioInterface(i).updateRILNetworkInterface();
               }
             }
           })
-          .then(() => this._destroyNetwork(networkInterface.name))
+          .then(() => this._destroyNetwork(extNetworkInfo.name))
           .then(() => {
             // Notify outer modules like MmsService to start the transaction after
             // the configuration of the network interface is done.
-            Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
-                                         this.convertConnectionType(network));
+            Services.obs.notifyObservers(network.info,
+                                         TOPIC_CONNECTION_STATE_CHANGED,
+                                         this.convertConnectionType(network.info));
           })
           .catch(aError => {
             debug("updateNetworkInterface error: " + aError);
           });
         break;
     }
   },
 
   unregisterNetworkInterface: function(network) {
     if (!(network instanceof Ci.nsINetworkInterface)) {
       throw Components.Exception("Argument must be nsINetworkInterface.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
-    let networkId = this.getNetworkId(network);
+    let networkId = this.getNetworkId(network.info);
     if (!(networkId in this.networkInterfaces)) {
       throw Components.Exception("No network with that type registered.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
 
     // This is for in case a network gets unregistered without being
     // DISCONNECTED.
-    if (this.isNetworkTypeMobile(network.type)) {
+    if (this.isNetworkTypeMobile(network.info.type)) {
       this._cleanupAllHostRoutes(networkId);
     }
 
     delete this.networkInterfaces[networkId];
 
-    Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
+    Services.obs.notifyObservers(network.info, TOPIC_INTERFACE_UNREGISTERED, null);
     debug("Network '" + networkId + "' unregistered.");
   },
 
   _manageOfflineStatus: true,
 
   networkInterfaces: null,
 
   networkInterfaceLinks: null,
 
   _preferredNetworkType: DEFAULT_PREFERRED_NETWORK_TYPE,
   get preferredNetworkType() {
     return this._preferredNetworkType;
   },
   set preferredNetworkType(val) {
-    if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
-         Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
+    if ([Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
+         Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
       throw "Invalid network type";
     }
     this._preferredNetworkType = val;
   },
 
-  active: null,
+  _activeNetwork: null,
+
+  get activeNetworkInfo() {
+    return this._activeNetwork && this._activeNetwork.info;
+  },
+
   _overriddenActive: null,
 
   overrideActive: function(network) {
-    if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
-         Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
+    let type = network.info.type;
+    if ([Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
+         Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE].indexOf(type) == -1) {
       throw "Invalid network type";
     }
 
     this._overriddenActive = network;
     this.setAndConfigureActive();
   },
 
   _updateRoutes: function(oldLinks, newLinks, gateways, interfaceName) {
@@ -543,90 +553,90 @@ NetworkManager.prototype = {
                                         networkName, aIpAddress,
                                         getMaxPrefixLength(aIpAddress), gateway));
       }
     });
 
     return Promise.all(promises);
   },
 
-  isValidatedNetwork: function(network) {
+  isValidatedNetwork: function(aNetworkInfo) {
     let isValid = false;
     try {
-      isValid = (this.getNetworkId(network) in this.networkInterfaces);
+      isValid = (this.getNetworkId(aNetworkInfo) in this.networkInterfaces);
     } catch (e) {
       debug("Invalid network interface: " + e);
     }
 
     return isValid;
   },
 
-  addHostRoute: function(network, host) {
-    if (!this.isValidatedNetwork(network)) {
-      return Promise.reject("Invalid network interface.");
+  addHostRoute: function(aNetworkInfo, aHost) {
+    if (!this.isValidatedNetwork(aNetworkInfo)) {
+      return Promise.reject("Invalid network info.");
     }
 
-    return this.resolveHostname(network, host)
+    return this.resolveHostname(aNetworkInfo, aHost)
       .then((ipAddresses) => {
         let promises = [];
-        let networkId = this.getNetworkId(network);
+        let networkId = this.getNetworkId(aNetworkInfo);
 
         ipAddresses.forEach((aIpAddress) => {
           let promise =
-            this._setHostRoutes(true, [aIpAddress], network.name, network.getGateways())
+            this._setHostRoutes(true, [aIpAddress], aNetworkInfo.name, aNetworkInfo.getGateways())
               .then(() => this.networkInterfaceLinks[networkId].extraRoutes.push(aIpAddress));
 
           promises.push(promise);
         });
 
         return Promise.all(promises);
       });
   },
 
-  removeHostRoute: function(network, host) {
-    if (!this.isValidatedNetwork(network)) {
-      return Promise.reject("Invalid network interface.");
+  removeHostRoute: function(aNetworkInfo, aHost) {
+    if (!this.isValidatedNetwork(aNetworkInfo)) {
+      return Promise.reject("Invalid network info.");
     }
 
-    return this.resolveHostname(network, host)
+    return this.resolveHostname(aNetworkInfo, aHost)
       .then((ipAddresses) => {
         let promises = [];
-        let networkId = this.getNetworkId(network);
+        let networkId = this.getNetworkId(aNetworkInfo);
 
         ipAddresses.forEach((aIpAddress) => {
           let found = this.networkInterfaceLinks[networkId].extraRoutes.indexOf(aIpAddress);
           if (found < 0) {
             return; // continue
           }
 
           let promise =
-            this._setHostRoutes(false, [aIpAddress], network.name, network.getGateways())
+            this._setHostRoutes(false, [aIpAddress], aNetworkInfo.name, aNetworkInfo.getGateways())
               .then(() => {
                 this.networkInterfaceLinks[networkId].extraRoutes.splice(found, 1);
               }, () => {
                 // We should remove it even if the operation failed.
                 this.networkInterfaceLinks[networkId].extraRoutes.splice(found, 1);
               });
           promises.push(promise);
         });
 
         return Promise.all(promises);
       });
   },
 
   isNetworkTypeSecondaryMobile: function(type) {
-    return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL ||
-            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS ||
-            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN ||
-            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA);
+    return (type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS ||
+            type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL ||
+            type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS ||
+            type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN ||
+            type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA);
   },
 
   isNetworkTypeMobile: function(type) {
-    return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
+    return (type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE ||
             this.isNetworkTypeSecondaryMobile(type));
   },
 
   _handleGateways: function(networkId, gateways) {
     let currentNetworkLinks = this.networkInterfaceLinks[networkId];
     if (currentNetworkLinks.gateways.length == 0 ||
         currentNetworkLinks.compareGateways(gateways)) {
       return Promise.resolve();
@@ -760,161 +770,163 @@ NetworkManager.prototype = {
     return Promise.all(promises);
   },
 
   /**
    * Determine the active interface and configure it.
    */
   setAndConfigureActive: function() {
     debug("Evaluating whether active network needs to be changed.");
-    let oldActive = this.active;
+    let oldActive = this._activeNetwork;
 
     if (this._overriddenActive) {
       debug("We have an override for the active network: " +
-            this._overriddenActive.name);
+            this._overriddenActive.info.name);
       // The override was just set, so reconfigure the network.
-      if (this.active != this._overriddenActive) {
-        this.active = this._overriddenActive;
-        this._setDefaultRouteAndProxy(this.active, oldActive);
-        Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
+      if (this._activeNetwork != this._overriddenActive) {
+        this._activeNetwork = this._overriddenActive;
+        this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
+        Services.obs.notifyObservers(this.activeNetworkInfo,
+                                     TOPIC_ACTIVE_CHANGED, null);
       }
       return;
     }
 
     // The active network is already our preferred type.
-    if (this.active &&
-        this.active.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED &&
-        this.active.type == this._preferredNetworkType) {
+    if (this.activeNetworkInfo &&
+        this.activeNetworkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED &&
+        this.activeNetworkInfo.type == this._preferredNetworkType) {
       debug("Active network is already our preferred type.");
-      return this._setDefaultRouteAndProxy(this.active, oldActive);
+      return this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
     }
 
     // Find a suitable network interface to activate.
-    this.active = null;
+    this._activeNetwork = null;
     let anyConnected = false;
 
     for each (let network in this.networkInterfaces) {
-      if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
+      if (network.info.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
         continue;
       }
       anyConnected = true;
 
       // Set active only for default connections.
-      if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI &&
-          network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
+      if (network.info.type != Ci.nsINetworkInfo.NETWORK_TYPE_WIFI &&
+          network.info.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
         continue;
       }
 
-      this.active = network;
-      if (network.type == this.preferredNetworkType) {
-        debug("Found our preferred type of network: " + network.name);
+      this._activeNetwork = network;
+      if (network.info.type == this.preferredNetworkType) {
+        debug("Found our preferred type of network: " + network.info.name);
         break;
       }
     }
 
     return Promise.resolve()
       .then(() => {
-        if (!this.active) {
+        if (!this._activeNetwork) {
           return Promise.resolve();
         }
 
-        return this._setDefaultRouteAndProxy(this.active, oldActive);
+        return this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
       })
       .then(() => {
-        if (this.active != oldActive) {
-          Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
+        if (this._activeNetwork != oldActive) {
+          Services.obs.notifyObservers(this.activeNetworkInfo,
+                                       TOPIC_ACTIVE_CHANGED, null);
         }
 
         if (this._manageOfflineStatus) {
           Services.io.offline = !anyConnected;
         }
       });
   },
 
-  resolveHostname: function(network, hostname) {
+  resolveHostname: function(aNetworkInfo, aHostname) {
     // Sanity check for null, undefined and empty string... etc.
-    if (!hostname) {
-      return Promise.reject(new Error("hostname is empty: " + hostname));
+    if (!aHostname) {
+      return Promise.reject(new Error("hostname is empty: " + aHostname));
     }
 
-    if (hostname.match(this.REGEXP_IPV4) ||
-        hostname.match(this.REGEXP_IPV6)) {
-      return Promise.resolve([hostname]);
+    if (aHostname.match(this.REGEXP_IPV4) ||
+        aHostname.match(this.REGEXP_IPV6)) {
+      return Promise.resolve([aHostname]);
     }
 
     // Wrap gDNSService.asyncResolveExtended to a promise, which
     // resolves with an array of ip addresses or rejects with
     // the reason otherwise.
     let hostResolveWrapper = aNetId => {
       return new Promise((aResolve, aReject) => {
         // Callback for gDNSService.asyncResolveExtended.
         let onLookupComplete = (aRequest, aRecord, aStatus) => {
           if (!Components.isSuccessCode(aStatus)) {
-            aReject(new Error("Failed to resolve '" + hostname +
+            aReject(new Error("Failed to resolve '" + aHostname +
                               "', with status: " + aStatus));
             return;
           }
 
           let retval = [];
           while (aRecord.hasMore()) {
             retval.push(aRecord.getNextAddrAsString());
           }
 
           if (!retval.length) {
             aReject(new Error("No valid address after DNS lookup!"));
             return;
           }
 
-          debug("hostname is resolved: " + hostname);
+          debug("hostname is resolved: " + aHostname);
           debug("Addresses: " + JSON.stringify(retval));
 
           aResolve(retval);
         };
 
-        debug('Calling gDNSService.asyncResolveExtended: ' + aNetId + ', ' + hostname);
-        gDNSService.asyncResolveExtended(hostname,
+        debug('Calling gDNSService.asyncResolveExtended: ' + aNetId + ', ' + aHostname);
+        gDNSService.asyncResolveExtended(aHostname,
                                          0,
                                          aNetId,
                                          onLookupComplete,
                                          Services.tm.mainThread);
       });
     };
 
     // TODO: |getNetId| will be implemented as a sync call in nsINetworkManager
     //       once Bug 1141903 is landed.
-    return gNetworkService.getNetId(network.name)
+    return gNetworkService.getNetId(aNetworkInfo.name)
       .then(aNetId => hostResolveWrapper(aNetId));
   },
 
-  convertConnectionType: function(network) {
+  convertConnectionType: function(aNetworkInfo) {
     // If there is internal interface change (e.g., MOBILE_MMS, MOBILE_SUPL),
     // the function will return null so that it won't trigger type change event
     // in NetworkInformation API.
-    if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI &&
-        network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
+    if (aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_WIFI &&
+        aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
       return null;
     }
 
-    if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED) {
+    if (aNetworkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED) {
       return CONNECTION_TYPE_NONE;
     }
 
-    switch (network.type) {
-      case Ci.nsINetworkInterface.NETWORK_TYPE_WIFI:
+    switch (aNetworkInfo.type) {
+      case Ci.nsINetworkInfo.NETWORK_TYPE_WIFI:
         return CONNECTION_TYPE_WIFI;
-      case Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE:
+      case Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE:
         return CONNECTION_TYPE_CELLULAR;
     }
   },
 
-  _setDNS: function(aNetwork) {
+  _setDNS: function(aNetworkInfo) {
     return new Promise((aResolve, aReject) => {
-      let dnses = aNetwork.getDnses();
-      let gateways = aNetwork.getGateways();
-      gNetworkService.setDNS(aNetwork.name, dnses.length, dnses,
+      let dnses = aNetworkInfo.getDnses();
+      let gateways = aNetworkInfo.getGateways();
+      gNetworkService.setDNS(aNetworkInfo.name, dnses.length, dnses,
                              gateways.length, gateways, (aError) => {
         if (aError) {
           aReject("setDNS failed");
           return;
         }
         aResolve();
       });
     });
@@ -951,65 +963,66 @@ NetworkManager.prototype = {
           debug("resetRoutingTable failed");
         }
         // Always resolve.
         aResolve();
       });
     });
   },
 
-  _removeDefaultRoute: function(aNetwork) {
+  _removeDefaultRoute: function(aNetworkInfo) {
     return new Promise((aResolve, aReject) => {
-      let gateways = aNetwork.getGateways();
-      gNetworkService.removeDefaultRoute(aNetwork.name, gateways.length,
+      let gateways = aNetworkInfo.getGateways();
+      gNetworkService.removeDefaultRoute(aNetworkInfo.name, gateways.length,
                                          gateways, (aSuccess) => {
         if (!aSuccess) {
           debug("removeDefaultRoute failed");
         }
         // Always resolve.
         aResolve();
       });
     });
   },
 
   _setDefaultRouteAndProxy: function(aNetwork, aOldInterface) {
     return new Promise((aResolve, aReject) => {
-      let gateways = aNetwork.getGateways();
-      let oldInterfaceName = (aOldInterface ? aOldInterface.name : "");
-      gNetworkService.setDefaultRoute(aNetwork.name, gateways.length, gateways,
+      let networkInfo = aNetwork.info;
+      let gateways = networkInfo.getGateways();
+      let oldInterfaceName = (aOldInterface ? aOldInterface.info.name : "");
+      gNetworkService.setDefaultRoute(networkInfo.name, gateways.length, gateways,
                                       oldInterfaceName, (aSuccess) => {
         if (!aSuccess) {
-          gNetworkService.destroyNetwork(aNetwork, function() {
+          gNetworkService.destroyNetwork(networkInfo.name, function() {
             aReject("setDefaultRoute failed");
           });
           return;
         }
         this.setNetworkProxy(aNetwork);
         aResolve();
       });
     });
   },
 
-  setNetworkProxy: function(network) {
+  setNetworkProxy: function(aNetwork) {
     try {
-      if (!network.httpProxyHost || network.httpProxyHost === "") {
+      if (!aNetwork.httpProxyHost || aNetwork.httpProxyHost === "") {
         // Sets direct connection to internet.
         this.clearNetworkProxy();
 
-        debug("No proxy support for " + network.name + " network interface.");
+        debug("No proxy support for " + aNetwork.info.name + " network interface.");
         return;
       }
 
-      debug("Going to set proxy settings for " + network.name + " network interface.");
+      debug("Going to set proxy settings for " + aNetwork.info.name + " network interface.");
 
       // Do not use this proxy server for all protocols.
       Services.prefs.setBoolPref("network.proxy.share_proxy_settings", false);
-      Services.prefs.setCharPref("network.proxy.http", network.httpProxyHost);
-      Services.prefs.setCharPref("network.proxy.ssl", network.httpProxyHost);
-      let port = network.httpProxyPort === 0 ? 8080 : network.httpProxyPort;
+      Services.prefs.setCharPref("network.proxy.http", aNetwork.httpProxyHost);
+      Services.prefs.setCharPref("network.proxy.ssl", aNetwork.httpProxyHost);
+      let port = aNetwork.httpProxyPort === 0 ? 8080 : aNetwork.httpProxyPort;
       Services.prefs.setIntPref("network.proxy.http_port", port);
       Services.prefs.setIntPref("network.proxy.ssl_port", port);
 
       let usePAC;
       try {
         usePAC = Services.prefs.getBoolPref("network.proxy.pac_generator");
       } catch (ex) {}
 
@@ -1017,17 +1030,17 @@ NetworkManager.prototype = {
         Services.prefs.setCharPref("network.proxy.autoconfig_url",
                                    gPACGenerator.generate());
         Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
       } else {
         Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_MANUAL);
       }
     } catch(ex) {
         debug("Exception " + ex + ". Unable to set proxy setting for " +
-              network.name + " network interface.");
+              aNetwork.info.name + " network interface.");
     }
   },
 
   clearNetworkProxy: function() {
     debug("Going to clear all network proxy.");
 
     Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
     Services.prefs.clearUserPref("network.proxy.http");
@@ -1100,27 +1113,27 @@ let CaptivePortalDetectionHelper = (func
   return {
     EVENT_CONNECT: EVENT_CONNECT,
     EVENT_DISCONNECT: EVENT_DISCONNECT,
     notify: function(eventType, network) {
       switch (eventType) {
         case EVENT_CONNECT:
           // perform captive portal detection on wifi interface
           if (_available && network &&
-              network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
+              network.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
             _performDetection(network.name, function() {
               // TODO: bug 837600
               // We can disconnect wifi in here if user abort the login procedure.
             });
           }
 
           break;
         case EVENT_DISCONNECT:
           if (_available &&
-              network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
+              network.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
             _abort(network.name);
           }
           break;
       }
     }
   };
 }());
 
--- a/dom/system/gonk/tests/marionette/head.js
+++ b/dom/system/gonk/tests/marionette/head.js
@@ -4,28 +4,28 @@
 MARIONETTE_CONTEXT = "chrome";
 
 const SETTINGS_KEY_DATA_ENABLED = "ril.data.enabled";
 const SETTINGS_KEY_DATA_APN_SETTINGS  = "ril.data.apnSettings";
 
 const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
 const TOPIC_NETWORK_ACTIVE_CHANGED = "network-active-changed";
 
-const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN;
-const NETWORK_STATE_CONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTING;
-const NETWORK_STATE_CONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
-const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTING;
-const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
+const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN;
+const NETWORK_STATE_CONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTING;
+const NETWORK_STATE_CONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
+const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTING;
+const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
 
-const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
-const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS;
-const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL;
-const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS;
-const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN;
-const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA;
+const NETWORK_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
+const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS;
+const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL;
+const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS;
+const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN;
+const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA;
 
 const networkTypes = [
   NETWORK_TYPE_MOBILE,
   NETWORK_TYPE_MOBILE_MMS,
   NETWORK_TYPE_MOBILE_SUPL,
   NETWORK_TYPE_MOBILE_IMS,
   NETWORK_TYPE_MOBILE_DUN,
   NETWORK_TYPE_MOBILE_FOTA
@@ -139,23 +139,23 @@ function waitForObserverEvent(aTopic) {
  *        A boolean state.
  *
  * @return A deferred promise.
  */
 function setDataEnabledAndWait(aEnabled) {
   let promises = [];
   promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
     .then(function(aSubject) {
-      ok(aSubject instanceof Ci.nsIRilNetworkInterface,
-         "subject should be an instance of nsIRILNetworkInterface");
+      ok(aSubject instanceof Ci.nsIRilNetworkInfo,
+         "subject should be an instance of nsIRilNetworkInfo");
       is(aSubject.type, NETWORK_TYPE_MOBILE,
          "subject.type should be " + NETWORK_TYPE_MOBILE);
       is(aSubject.state,
-         aEnabled ? Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
-                  : Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
+         aEnabled ? Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED
+                  : Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
          "subject.state should be " + aEnabled ? "CONNECTED" : "DISCONNECTED");
     }));
   promises.push(setSettings(SETTINGS_KEY_DATA_ENABLED, aEnabled));
 
   return Promise.all(promises);
 }
 
 /**
@@ -170,21 +170,21 @@ function setDataEnabledAndWait(aEnabled)
  * @return A deferred promise.
  */
 function setupDataCallAndWait(aNetworkType) {
   log("setupDataCallAndWait: " + aNetworkType);
 
   let promises = [];
   promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
     .then(function(aSubject) {
-      ok(aSubject instanceof Ci.nsIRilNetworkInterface,
-         "subject should be an instance of nsIRILNetworkInterface");
+      ok(aSubject instanceof Ci.nsIRilNetworkInfo,
+         "subject should be an instance of nsIRilNetworkInfo");
       is(aSubject.type, aNetworkType,
          "subject.type should be " + aNetworkType);
-      is(aSubject.state, Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED,
+      is(aSubject.state, Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED,
          "subject.state should be CONNECTED");
     }));
   promises.push(radioInterface.setupDataCallByType(aNetworkType));
 
   return Promise.all(promises);
 }
 
 /**
@@ -199,21 +199,21 @@ function setupDataCallAndWait(aNetworkTy
  * @return A deferred promise.
  */
 function deactivateDataCallAndWait(aNetworkType) {
   log("deactivateDataCallAndWait: " + aNetworkType);
 
   let promises = [];
   promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
     .then(function(aSubject) {
-      ok(aSubject instanceof Ci.nsIRilNetworkInterface,
-         "subject should be an instance of nsIRILNetworkInterface");
+      ok(aSubject instanceof Ci.nsIRilNetworkInfo,
+         "subject should be an instance of nsIRilNetworkInfo");
       is(aSubject.type, aNetworkType,
          "subject.type should be " + aNetworkType);
-      is(aSubject.state, Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
+      is(aSubject.state, Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
          "subject.state should be DISCONNECTED");
     }));
   promises.push(radioInterface.deactivateDataCallByType(aNetworkType));
 
   return Promise.all(promises);
 }
 
 /**
--- a/dom/system/gonk/tests/marionette/test_network_active_changed.js
+++ b/dom/system/gonk/tests/marionette/test_network_active_changed.js
@@ -8,42 +8,42 @@ let networkManager =
   Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
 ok(networkManager,
    "networkManager.constructor is " + networkManager.constructor);
 
 function testInitialState() {
   return getSettings(SETTINGS_KEY_DATA_ENABLED)
     .then((enabled) => {
       is(enabled, false, "data should be off by default");
-      is(networkManager.active, null,
-         "networkManager.active should be null by default");
+      is(networkManager.activeNetworkInfo, null,
+         "networkManager.activeNetworkInfo should be null by default");
     });
 }
 
 function testActiveNetworkChangedBySwitchingDataCall(aDataCallEnabled) {
   log("Test active network by switching dataCallEnabled to " + aDataCallEnabled);
 
   let promises = [];
   promises.push(waitForObserverEvent(TOPIC_NETWORK_ACTIVE_CHANGED));
   promises.push(setSettings(SETTINGS_KEY_DATA_ENABLED, aDataCallEnabled));
 
   return Promise.all(promises).then(function(results) {
     let subject = results[0];
 
     if (aDataCallEnabled) {
-      ok(subject instanceof Ci.nsINetworkInterface,
-         "subject should be an instance of nsINetworkInterface");
-      ok(subject instanceof Ci.nsIRilNetworkInterface,
-         "subject should be an instance of nsIRILNetworkInterface");
+      ok(subject instanceof Ci.nsINetworkInfo,
+         "subject should be an instance of nsINetworkInfo");
+      ok(subject instanceof Ci.nsIRilNetworkInfo,
+         "subject should be an instance of nsIRilNetworkInfo");
       is(subject.type, NETWORK_TYPE_MOBILE,
          "subject.type should be NETWORK_TYPE_MOBILE");
     }
 
-    is(subject, networkManager.active,
-       "subject should be equal with networkManager.active");
+    is(subject, networkManager.activeNetworkInfo,
+       "subject should be equal with networkManager.activeNetworkInfo");
   });
 }
 
 // Start test
 startTestBase(function() {
   return testInitialState()
     // Test active network changed by enabling data call.
     .then(() => testActiveNetworkChangedBySwitchingDataCall(true))