Bug 1371550 - create worker thread before it is required; r=bagder
authorLiang-Heng Chen <xeonchen@gmail.com>
Fri, 09 Jun 2017 15:11:24 +0800
changeset 413787 e5fe50da0571a67e4ad62aeb9e13013eba5369c8
parent 413786 a2d018ad5a124009910072387c54c61303835a41
child 413788 73eefb81f8e15845cf63cd809047c80b7ac8e3f5
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder
bugs1371550
milestone55.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 1371550 - create worker thread before it is required; r=bagder MozReview-Commit-ID: 9DydRQwOHyT
netwerk/base/nsProtocolProxyService.cpp
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -508,16 +508,18 @@ nsProtocolProxyService::~nsProtocolProxy
     NS_ASSERTION(mHostFiltersArray.Length() == 0 && mFilters == nullptr &&
                  mPACMan == nullptr, "what happened to xpcom-shutdown?");
 }
 
 // nsProtocolProxyService methods
 nsresult
 nsProtocolProxyService::Init()
 {
+    NS_NewNamedThread("SysProxySetting", getter_AddRefs(mProxySettingThread));
+
     // failure to access prefs is non-fatal
     nsCOMPtr<nsIPrefBranch> prefBranch =
             do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefBranch) {
         // monitor proxy prefs
         prefBranch->AddObserver(PROXY_PREF_BRANCH, this, false);
 
         // read all prefs
@@ -527,18 +529,16 @@ nsProtocolProxyService::Init()
     nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
     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);
     }
 
-    NS_NewNamedThread("SysProxySetting", getter_AddRefs(mProxySettingThread));
-
     return NS_OK;
 }
 
 // ReloadNetworkPAC() checks if there's a non-networked PAC in use then avoids
 // to call ReloadPAC()
 nsresult
 nsProtocolProxyService::ReloadNetworkPAC()
 {
@@ -585,20 +585,16 @@ nsProtocolProxyService::ReloadNetworkPAC
 }
 
 nsresult
 nsProtocolProxyService::AsyncConfigureFromPAC(bool aForceReload,
                                               bool aResetPACThread)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
-    if (NS_WARN_IF(!mProxySettingThread)) {
-        return NS_ERROR_NOT_INITIALIZED;
-    }
-
     bool mainThreadOnly;
     nsresult rv = mSystemProxySettings->GetMainThreadOnly(&mainThreadOnly);
     if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
     }
 
     nsCOMPtr<nsIRunnable> req =
         new AsyncGetPACURIRequest(this,
@@ -606,16 +602,20 @@ nsProtocolProxyService::AsyncConfigureFr
                                   mSystemProxySettings,
                                   mainThreadOnly,
                                   aForceReload,
                                   aResetPACThread);
 
     if (mainThreadOnly) {
         return req->Run();
     }
+
+    if (NS_WARN_IF(!mProxySettingThread)) {
+        return NS_ERROR_NOT_INITIALIZED;
+    }
     return mProxySettingThread->Dispatch(req, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 nsresult
 nsProtocolProxyService::OnAsyncGetPACURI(bool aForceReload,
                                          bool aResetPACThread,
                                          nsresult aResult,
                                          const nsACString& aUri)