Bug 1595242 - Move the offthread negotiate auth to dispatch to the background thread pool r=mayhemer
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 15 Nov 2019 19:45:17 +0000
changeset 502275 f7679d8469b66ed60ad902806b67ebfff4c58e5f
parent 502274 c1e961421fe1aea3523b6fdf4dba49126a70f6a7
child 502276 ffc51f312b5a44b57997bb3cae8cbb18a8234053
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1595242
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 1595242 - Move the offthread negotiate auth to dispatch to the background thread pool r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D52904
extensions/auth/nsHttpNegotiateAuth.cpp
extensions/auth/nsHttpNegotiateAuth.h
--- a/extensions/auth/nsHttpNegotiateAuth.cpp
+++ b/extensions/auth/nsHttpNegotiateAuth.cpp
@@ -321,17 +321,17 @@ class GetNextTokenCompleteEvent final : 
 };
 
 NS_IMPL_ISUPPORTS(GetNextTokenCompleteEvent, nsIRunnable, nsICancelable)
 
 //
 // GetNextTokenRunnable
 //
 // This runnable is created by GenerateCredentialsAsync and it runs
-// in nsHttpNegotiateAuth::mNegotiateThread and calling GenerateCredentials.
+// on the background thread pool and calls GenerateCredentials.
 //
 class GetNextTokenRunnable final : public mozilla::Runnable {
   ~GetNextTokenRunnable() override = default;
 
  public:
   GetNextTokenRunnable(nsIHttpAuthenticableChannel* authChannel,
                        const char* challenge, bool isProxyAuth,
                        const char16_t* domain, const char16_t* username,
@@ -431,27 +431,22 @@ nsHttpNegotiateAuth::GenerateCredentials
   NS_ENSURE_ARG_POINTER(aCancelable);
 
   RefPtr<GetNextTokenCompleteEvent> cancelEvent =
       new GetNextTokenCompleteEvent(aCallback);
 
   nsCOMPtr<nsIRunnable> getNextTokenRunnable = new GetNextTokenRunnable(
       authChannel, challenge, isProxyAuth, domain, username, password,
       sessionState, continuationState, cancelEvent);
-  cancelEvent.forget(aCancelable);
 
-  nsresult rv;
-  if (!mNegotiateThread) {
-    mNegotiateThread = new mozilla::LazyIdleThread(
-        DEFAULT_THREAD_TIMEOUT_MS, NS_LITERAL_CSTRING("NegotiateAuth"));
-    NS_ENSURE_TRUE(mNegotiateThread, NS_ERROR_OUT_OF_MEMORY);
-  }
-  rv = mNegotiateThread->Dispatch(getNextTokenRunnable, NS_DISPATCH_NORMAL);
+  nsresult rv = NS_DispatchBackgroundTask(
+      getNextTokenRunnable, nsIEventTarget::DISPATCH_EVENT_MAY_BLOCK);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  cancelEvent.forget(aCancelable);
   return NS_OK;
 }
 
 //
 // GenerateCredentials
 //
 // This routine is responsible for creating the correct authentication
 // blob to pass to the server that requested "Negotiate" authentication.
--- a/extensions/auth/nsHttpNegotiateAuth.h
+++ b/extensions/auth/nsHttpNegotiateAuth.h
@@ -26,15 +26,12 @@ class nsHttpNegotiateAuth final : public
   ~nsHttpNegotiateAuth() {}
 
   // returns the value of the given boolean pref
   bool TestBoolPref(const char* pref);
 
   // tests if the host part of an uri is fully qualified
   bool TestNonFqdn(nsIURI* uri);
 
-  // Thread for GenerateCredentialsAsync
-  RefPtr<mozilla::LazyIdleThread> mNegotiateThread;
-
   // Singleton pointer
   static mozilla::StaticRefPtr<nsHttpNegotiateAuth> gSingleton;
 };
 #endif /* nsHttpNegotiateAuth_h__ */