Bug 1323100 - Use NS_NewNamedThread to name the proxy resolution thread. r?froydnj draft
authorMarkus Stange <mstange@themasta.com>
Wed, 14 Dec 2016 17:16:01 -0500
changeset 456868 b12772888df54e977876ed050d2ff7f12669a794
parent 456716 a14094edbad78fc1d16e8d4c57902537cf286fd1
child 456869 7a0065d2d5f9d1bb0a93540895741f218dbc4c07
push id40636
push userbmo:mstange@themasta.com
push dateFri, 06 Jan 2017 12:38:48 +0000
reviewersfroydnj
bugs1323100
milestone53.0a1
Bug 1323100 - Use NS_NewNamedThread to name the proxy resolution thread. r?froydnj MozReview-Commit-ID: Fqxr4XmvS7I
netwerk/base/nsPACMan.cpp
netwerk/base/nsPACMan.h
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -737,33 +737,21 @@ nsPACMan::AsyncOnChannelRedirect(nsIChan
   // However do track the most recent URI in the redirect change
   // as mPACURIRedirectSpec so that URI can be allowed to bypass
   // the proxy and actually fetch the pac file.
 
   callback->OnRedirectVerifyCallback(NS_OK);
   return NS_OK;
 }
 
-void
-nsPACMan::NamePACThread()
-{
-  MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
-  PR_SetCurrentThreadName("Proxy Resolution");
-}
-
 nsresult
 nsPACMan::Init(nsISystemProxySettings *systemProxySettings)
 {
   mSystemProxySettings = systemProxySettings;
 
-  nsresult rv = NS_NewThread(getter_AddRefs(mPACThread), nullptr);
-  if (NS_FAILED(rv))
-    return rv;
+  nsresult rv =
+    NS_NewNamedThread("ProxyResolution", getter_AddRefs(mPACThread));
 
-  // don't check return value as it is not a big deal for this to fail.
-  mPACThread->Dispatch(NewRunnableMethod(this, &nsPACMan::NamePACThread),
-                       nsIEventTarget::DISPATCH_NORMAL);
-
-  return NS_OK;
+  return rv;
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/base/nsPACMan.h
+++ b/netwerk/base/nsPACMan.h
@@ -209,17 +209,16 @@ private:
    * execute the queue if it was otherwise empty
    */
   nsresult PostQuery(PendingPACQuery *query);
 
   // PAC thread operations only
   void PostProcessPendingQ();
   void PostCancelPendingQ(nsresult);
   bool ProcessPending();
-  void NamePACThread();
 
 private:
   ProxyAutoConfig mPAC;
   nsCOMPtr<nsIThread>           mPACThread;
   nsCOMPtr<nsISystemProxySettings> mSystemProxySettings;
 
   LinkedList<PendingPACQuery> mPendingQ; /* pac thread only */