Bug 1594858 - Move CanEnableSpeculativeConnect call to the background thread. r=mayhemer
authorKristen Wright <kwright@mozilla.com>
Mon, 11 Nov 2019 18:00:38 +0000
changeset 501499 ce47bb582ecb9fb5157eea28a70b95a7454c4014
parent 501498 d3163cbe3b006771c30dc8f2cb625bb9cb89b362
child 501500 1da01fcd3539d8d82362ef0a3ac4d5a4c42a6826
push id36794
push useraciure@mozilla.com
push dateTue, 12 Nov 2019 09:43:07 +0000
treeherdermozilla-central@5f0b392beadb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1594858
milestone72.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 1594858 - Move CanEnableSpeculativeConnect call to the background thread. r=mayhemer Instead of spinning up a LazyIdleThread for this check, just use the background thread pool. Differential Revision: https://phabricator.services.mozilla.com/D52240
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -438,19 +438,16 @@ nsresult nsHttpHandler::Init() {
   nsCOMPtr<nsIIOService> service = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) {
     NS_WARNING("unable to continue without io service");
     return rv;
   }
   mIOService = new nsMainThreadPtrHolder<nsIIOService>(
       "nsHttpHandler::mIOService", service);
 
-  mBackgroundThread = new mozilla::LazyIdleThread(
-      10000, NS_LITERAL_CSTRING("HTTP Handler Background"));
-
   if (IsNeckoChild()) NeckoChild::InitNeckoChild();
 
   InitUserAgentComponents();
 
   // This perference is only used in parent process.
   if (!IsNeckoChild()) {
     mActiveTabPriority =
         Preferences::GetBool(HTTP_PREF("active_tab_priority"), true);
@@ -2358,25 +2355,19 @@ static bool CanEnableSpeculativeConnect(
 void nsHttpHandler::MaybeEnableSpeculativeConnect() {
   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
 
   // We don't need to and can't check this in the child process.
   if (IsNeckoChild()) {
     return;
   }
 
-  if (!mBackgroundThread) {
-    NS_WARNING(
-        "nsHttpHandler::MaybeEnableSpeculativeConnect() no background thread");
-    return;
-  }
-
   net_EnsurePSMInit();
 
-  mBackgroundThread->Dispatch(
+  NS_DispatchBackgroundTask(
       NS_NewRunnableFunction("CanEnableSpeculativeConnect", [] {
         gHttpHandler->mSpeculativeConnectEnabled =
             CanEnableSpeculativeConnect();
       }));
 }
 
 nsresult nsHttpHandler::SpeculativeConnectInternal(
     nsIURI* aURI, nsIPrincipal* aPrincipal, nsIInterfaceRequestor* aCallbacks,
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -507,20 +507,16 @@ class nsHttpHandler final : public nsIHt
 
   // the authentication credentials cache
   nsHttpAuthCache mAuthCache;
   nsHttpAuthCache mPrivateAuthCache;
 
   // the connection manager
   RefPtr<nsHttpConnectionMgr> mConnMgr;
 
-  // This thread is used for performing operations that should not block
-  // the main thread.
-  nsCOMPtr<nsIThread> mBackgroundThread;
-
   //
   // prefs
   //
 
   enum HttpVersion mHttpVersion;
   enum HttpVersion mProxyHttpVersion;
   uint32_t mCapabilities;