Bug 1166274 - Part 1: Handle the callback and IPC message of setStaticIpMode correctly. r=vchang
authorEdgar Chen <echen@mozilla.com>
Fri, 13 Feb 2015 16:03:49 +0800
changeset 269581 86ab6cc5a3ae6ae92d7924d96f57a9df3d615755
parent 269580 eecddaa2cc3c5348976886c87bc32b3b22eeee02
child 269582 e532ebecafc6bedcf1024a90f5d3c985bee3ec3b
push id2540
push userwcosta@mozilla.com
push dateWed, 03 Jun 2015 20:55:41 +0000
reviewersvchang
bugs1166274
milestone41.0a1
Bug 1166274 - Part 1: Handle the callback and IPC message of setStaticIpMode correctly. r=vchang
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -411,17 +411,17 @@ var WifiManager = (function() {
 
   var staticIpConfig = Object.create(null);
   function setStaticIpMode(network, info, callback) {
     let setNetworkKey = getNetworkKey(network);
     let curNetworkKey = null;
     let currentNetwork = Object.create(null);
     currentNetwork.netId = manager.connectionInfo.id;
 
-    manager.getNetworkConfiguration(currentNetwork, function (){
+    manager.getNetworkConfiguration(currentNetwork, function () {
       curNetworkKey = getNetworkKey(currentNetwork);
 
       // Add additional information to static ip configuration
       // It is used to compatiable with information dhcp callback.
       info.ipaddr = netHelpers.stringToIP(info.ipaddr_str);
       info.gateway = netHelpers.stringToIP(info.gateway_str);
       info.mask_str = netHelpers.ipToString(netHelpers.makeMask(info.maskLength));
 
@@ -430,25 +430,29 @@ var WifiManager = (function() {
       info.dns2 = netHelpers.stringToIP(info.dns2_str);
       info.proxy = netHelpers.stringToIP(info.proxy_str);
 
       staticIpConfig[setNetworkKey] = info;
 
       // If the ssid of current connection is the same as configured ssid
       // It means we need update current connection to use static IP address.
       if (setNetworkKey == curNetworkKey) {
-        // Use configureInterface directly doesn't work, the network iterface
+        // Use configureInterface directly doesn't work, the network interface
         // and routing table is changed but still cannot connect to network
         // so the workaround here is disable interface the enable again to
         // trigger network reconnect with static ip.
         gNetworkService.disableInterface(manager.ifname, function (ok) {
           gNetworkService.enableInterface(manager.ifname, function (ok) {
+            callback(ok);
           });
         });
+        return;
       }
+
+      callback(true);
     });
   }
 
   var dhcpInfo = null;
 
   function runStaticIp(ifname, key) {
     debug("Run static ip");
 
@@ -3489,17 +3493,17 @@ WifiWorker.prototype = {
         self._sendMessage(message, true, true, msg);
       } else {
         self._sendMessage(message, false, "Set http proxy failed", msg);
       }
     });
   },
 
   setStaticIpMode: function(msg) {
-    const message = "WifiManager:setStaticMode:Return";
+    const message = "WifiManager:setStaticIpMode:Return";
     let self = this;
     let network = msg.data.network;
     let info = msg.data.info;
 
     if (!WifiManager.enabled) {
       this._sendMessage(message, false, "Wifi is disabled", msg);
       return;
     }