Bug 939318 - protocolproxy service acts on network interface changes. r=mcmanus
☠☠ backed out by f9bfe115fee5 ☠ ☠
authorDaniel Stenberg <daniel@haxx.se>
Sun, 24 Aug 2014 23:20:00 -0400
changeset 223279 eeb8897aaa599841602c4bfcd39f37fc38fe0ea6
parent 223278 d1e1ca369322e47fc9ee740fc040b6140a77924e
child 223280 a2d39ac660a68f5a66e5f1c6999669709784874d
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs939318
milestone34.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 939318 - protocolproxy service acts on network interface changes. r=mcmanus
netwerk/base/src/nsProtocolProxyService.cpp
--- a/netwerk/base/src/nsProtocolProxyService.cpp
+++ b/netwerk/base/src/nsProtocolProxyService.cpp
@@ -24,16 +24,17 @@
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "prnetdb.h"
 #include "nsPACMan.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/CondVar.h"
 #include "nsISystemProxySettings.h"
+#include "nsINetworkLinkService.h"
 
 //----------------------------------------------------------------------------
 
 namespace mozilla {
   extern const char kProxyType_HTTP[];
   extern const char kProxyType_HTTPS[];
   extern const char kProxyType_SOCKS[];
   extern const char kProxyType_SOCKS4[];
@@ -409,21 +410,25 @@ nsProtocolProxyService::Init()
     if (prefBranch) {
         // monitor proxy prefs
         prefBranch->AddObserver(PROXY_PREF_BRANCH, this, false);
 
         // read all prefs
         PrefsChanged(prefBranch, nullptr);
     }
 
-    // register for shutdown notification so we can clean ourselves up properly.
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs)
+    if (obs) {
+        // register for shutdown notification so we can clean ourselves up
+        // properly.
         obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
 
+        obs->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);
+    }
+
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProtocolProxyService::Observe(nsISupports     *aSubject,
                                 const char      *aTopic,
                                 const char16_t *aData)
 {
@@ -435,16 +440,23 @@ nsProtocolProxyService::Observe(nsISuppo
         if (mFilters) {
             delete mFilters;
             mFilters = nullptr;
         }
         if (mPACMan) {
             mPACMan->Shutdown();
             mPACMan = nullptr;
         }
+    } else if (strcmp(aTopic, NS_NETWORK_LINK_TOPIC) == 0) {
+        nsCString converted = NS_ConvertUTF16toUTF8(aData);
+        const char *state = converted.get();
+        if (strcmp(state, NS_NETWORK_LINK_DATA_CHANGED) == 0) {
+            LOG((": received network event: %s, reload PAC", state));
+            ReloadPAC();
+        }
     }
     else {
         NS_ASSERTION(strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
                      "what is this random observer event?");
         nsCOMPtr<nsIPrefBranch> prefs = do_QueryInterface(aSubject);
         if (prefs)
             PrefsChanged(prefs, NS_LossyConvertUTF16toASCII(aData).get());
     }