Bug 1167132 - Part 8: [NetworkManager] Move network information into a separate interface (Mms). r=btseng
authorJessica Jong <jjong@mozilla.com>
Wed, 29 Jul 2015 02:10:00 -0400
changeset 286950 b61a73af6333694a3eb7982baf7984cf6d81f300
parent 286949 b6dc4da81f01d44da978b3f9e683e0f0bbfedb99
child 286951 d922c89bb2128d8cf5f74024fdc3fc77a5c6260e
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)
reviewersbtseng
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 8: [NetworkManager] Move network information into a separate interface (Mms). r=btseng
dom/mobilemessage/gonk/MmsService.js
--- a/dom/mobilemessage/gonk/MmsService.js
+++ b/dom/mobilemessage/gonk/MmsService.js
@@ -222,20 +222,20 @@ function MmsConnection(aServiceId) {
 MmsConnection.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 
   /** MMS proxy settings. */
   mmsc:     "",
   mmsProxy: "",
   mmsPort:  -1,
 
-  setApnSetting: function(network) {
-    this.mmsc = network.mmsc;
-    this.mmsProxy = network.mmsProxy;
-    this.mmsPort = network.mmsPort;
+  setApnSetting: function(networkInfo) {
+    this.mmsc = networkInfo.mmsc;
+    this.mmsProxy = networkInfo.mmsProxy;
+    this.mmsPort = networkInfo.mmsPort;
   },
 
   get proxyInfo() {
     if (!this.mmsProxy) {
       if (DEBUG) debug("getProxyInfo: MMS proxy is not available.");
       return null;
     }
 
@@ -263,18 +263,18 @@ MmsConnection.prototype = {
   pendingCallbacks: null,
 
   /** MMS network connection reference count. */
   refCount: 0,
 
   // cache of hosts to be accessed when this connection is alive.
   hostsToRoute: null,
 
-  // cache of the networkInterface acquired during this connection.
-  networkInterface: null,
+  // cache of the networkInfo acquired during this connection.
+  networkInfo: null,
 
   connectTimer: null,
 
   disconnectTimer: null,
 
   /**
    * Callback when |connectTimer| is timeout or cancelled by shutdown.
    */
@@ -298,24 +298,24 @@ MmsConnection.prototype = {
       return;
     }
 
     let deactivateMmsDataCall = (aError) => {
       if (aError) debug("Failed to removeHostRoute: " + aError);
 
       // Clear cache.
       this.hostsToRoute = [];
-      this.networkInterface = null;
+      this.networkInfo = null;
 
-      this.radioInterface.deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS);
+      this.radioInterface.deactivateDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
     };
 
     let promises =
       this.hostsToRoute.map((aHost) => {
-        return gNetworkManager.removeHostRoute(this.networkInterface, aHost);
+        return gNetworkManager.removeHostRoute(this.networkInfo, aHost);
       });
 
     return Promise.all(promises)
       .then(() => deactivateMmsDataCall(),
             (aError) => deactivateMmsDataCall(aError));
   },
 
   init: function() {
@@ -437,17 +437,17 @@ MmsConnection.prototype = {
       // MMS network fails to be connected within a time period.
       this.connectTimer.
         initWithCallback(() => this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_TIMEOUT),
                          TIME_TO_BUFFER_MMS_REQUESTS,
                          Ci.nsITimer.TYPE_ONE_SHOT);
 
       // Bug 1059110: Ensure all the initialization are done before setup data call.
       if (DEBUG) debug("acquire: buffer the MMS request and setup the MMS data call.");
-      this.radioInterface.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS);
+      this.radioInterface.setupDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
 
       return false;
     }
 
     callback(true, _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS);
     return true;
   },
 
@@ -489,17 +489,17 @@ MmsConnection.prototype = {
       host = url;
     }
 
     try {
       let uri = Services.io.newURI(host, null, null);
       host = uri.host;
     } catch (e) {}
 
-    return gNetworkManager.addHostRoute(this.networkInterface, host)
+    return gNetworkManager.addHostRoute(this.networkInfo, host)
       .then(() => {
         if (this.hostsToRoute.indexOf(host) < 0) {
           this.hostsToRoute.push(host);
         }
       });
   },
 
   shutdown: function() {
@@ -512,50 +512,50 @@ MmsConnection.prototype = {
     this.onDisconnectTimerTimeout();
   },
 
   // nsIObserver
 
   observe: function(subject, topic, data) {
     switch (topic) {
       case kNetworkConnStateChangedTopic: {
-        // The network for MMS connection must be nsIRilNetworkInterface.
-        if (!(subject instanceof Ci.nsIRilNetworkInterface)) {
+        // The network info for MMS connection must be nsIRilNetworkInfo.
+        if (!(subject instanceof Ci.nsIRilNetworkInfo)) {
           return;
         }
 
         // Check if the network state change belongs to this service.
-        let network = subject.QueryInterface(Ci.nsIRilNetworkInterface);
-        if (network.serviceId != this.serviceId ||
-            network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
+        let networkInfo = subject.QueryInterface(Ci.nsIRilNetworkInfo);
+        if (networkInfo.serviceId != this.serviceId ||
+            networkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS) {
           return;
         }
 
         let connected =
-          network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
+          networkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
 
         // Return if the MMS network state doesn't change, where the network
         // state change can come from other non-MMS networks.
         if (connected == this.connected) {
           return;
         }
 
         this.connected = connected;
         if (!this.connected) {
           this.hostsToRoute = [];
-          this.networkInterface = null;
+          this.networkInfo = null;
           return;
         }
 
         // Set up the MMS APN setting based on the connected MMS network,
         // which is going to be used for the HTTP requests later.
-        this.setApnSetting(network);
+        this.setApnSetting(networkInfo);
 
-        // Cache connected network.
-        this.networkInterface = network;
+        // Cache connected network info.
+        this.networkInfo = networkInfo;
 
         if (DEBUG) debug("Got the MMS network connected! Resend the buffered " +
                          "MMS requests: number: " + this.pendingCallbacks.length);
         this.connectTimer.cancel();
         this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS);
         break;
       }
       case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
@@ -740,17 +740,17 @@ XPCOMUtils.defineLazyGetter(this, "gMmsT
           debug('Failed to start a transaction: ' + aReason);
           mmsConnection.release();
           cancellable.done(_HTTP_STATUS_FAILED_TO_ROUTE, null);
         };
 
         // TODO: |getNetId| will be implemented as a sync call in nsINetworkManager
         //       once Bug 1141903 is landed.
         mmsConnection.ensureRouting(url)
-          .then(() => gNetworkService.getNetId(mmsConnection.networkInterface.name))
+          .then(() => gNetworkService.getNetId(mmsConnection.networkInfo.name))
           .then((netId) => startTransaction(netId))
           .catch((aReason) => onRejected(aReason));
       });
 
       return cancellable;
     },
 
     sendHttpRequest: function(mmsConnection, method, url, istream, proxyFilter,