Bug 990458 - Part 3: WifiWorker changes to support updateNetworkInterface(). r=vchang
authorJessica Jong <jjong@mozilla.com>
Tue, 29 Jul 2014 16:44:27 +0800
changeset 196674 0531a7a7f17e13567932e760c8800bcd27b7c098
parent 196673 2be828e5fbd28b31bfcea716cb72076b4de42dc7
child 196675 f03a68ec40ed0f11e8604cc15444b0b4a89a3430
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersvchang
bugs990458
milestone34.0a1
Bug 990458 - Part 3: WifiWorker changes to support updateNetworkInterface(). r=vchang
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -19,17 +19,16 @@ Cu.import("resource://gre/modules/WifiP2
 
 var DEBUG = false; // set to true to show debug messages.
 
 const WIFIWORKER_CONTRACTID = "@mozilla.org/wifi/worker;1";
 const WIFIWORKER_CID        = Components.ID("{a14e8977-d259-433a-a88d-58dd44657e5b}");
 
 const WIFIWORKER_WORKER     = "resource://gre/modules/wifi_worker.js";
 
-const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
 const kMozSettingsChangedObserverTopic   = "mozsettings-changed";
 
 const MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2;
 const MAX_SUPPLICANT_LOOP_ITERATIONS = 4;
 const MAX_RETRIES_ON_DHCP_FAILURE = 2;
 
 // Settings DB path for wifi
 const SETTINGS_WIFI_ENABLED            = "wifi.enabled";
@@ -974,19 +973,18 @@ var WifiManager = (function() {
         gNetworkManager.registerNetworkInterface(WifiNetworkInterface);
         WifiNetworkInterface.registered = true;
       }
       WifiNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
       WifiNetworkInterface.ips = [];
       WifiNetworkInterface.prefixLengths = [];
       WifiNetworkInterface.gateways = [];
       WifiNetworkInterface.dnses = [];
-      Services.obs.notifyObservers(WifiNetworkInterface,
-                                   kNetworkInterfaceStateChangedTopic,
-                                   null);
+      gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
+
       prepareForStartup(function() {
         loadDriver(function (status) {
           if (status < 0) {
             callback(status);
             manager.state = "UNINITIALIZED";
             return;
           }
           // This command is mandatory for Nexus 4. But some devices like
@@ -2180,19 +2178,17 @@ function WifiWorker() {
         });
 
         WifiNetworkInterface.state =
           Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
         WifiNetworkInterface.ips = [];
         WifiNetworkInterface.prefixLengths = [];
         WifiNetworkInterface.gateways = [];
         WifiNetworkInterface.dnses = [];
-        Services.obs.notifyObservers(WifiNetworkInterface,
-                                     kNetworkInterfaceStateChangedTopic,
-                                     null);
+        gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
 
         break;
       case "WPS_TIMEOUT":
         self._fireEvent("onwpstimeout", {});
         break;
       case "WPS_FAIL":
         self._fireEvent("onwpsfail", {});
         break;
@@ -2230,19 +2226,17 @@ function WifiWorker() {
     if (typeof this.info.dns1_str == "string" &&
         this.info.dns1_str.length) {
       WifiNetworkInterface.dnses.push(this.info.dns1_str);
     }
     if (typeof this.info.dns2_str == "string" &&
         this.info.dns2_str.length) {
       WifiNetworkInterface.dnses.push(this.info.dns2_str);
     }
-    Services.obs.notifyObservers(WifiNetworkInterface,
-                                 kNetworkInterfaceStateChangedTopic,
-                                 null);
+    gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
 
     self.ipAddress = this.info.ipaddr_str;
 
     // We start the connection information timer when we associate, but
     // don't have our IP address until here. Make sure that we fire a new
     // connectionInformation event with the IP address the next time the
     // timer fires.
     self._lastConnectionInfo = null;