Bug 1320289 - register STS thread to gecko profiler. r=cyu,mayhemer
authorShih-Chiang Chien <schien@mozilla.com>
Fri, 25 Nov 2016 18:07:06 +0800
changeset 324584 db8158d1b31db9c687774b9d9673025b59a710e5
parent 324583 fd9319f6ddce19f9b21dfc1b1888b13df7b24e8d
child 324585 c27b65f7a0c7b1b970e1e4b829187e46464314ba
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerscyu, mayhemer
bugs1320289
milestone53.0a1
Bug 1320289 - register STS thread to gecko profiler. r=cyu,mayhemer MozReview-Commit-ID: IzDNHDYAgsT
netwerk/base/nsSocketTransportService2.cpp
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -819,16 +819,21 @@ void
 nsSocketTransportService::MarkTheLastElementOfPendingQueue()
 {
     mServingPendingQueue = false;
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::Run()
 {
+#ifdef MOZ_ENABLE_PROFILER_SPS
+    char stackBaseGuess; // Need to be the first variable of main loop function.
+    profiler_register_thread(PR_GetThreadName(PR_GetCurrentThread()), &stackBaseGuess);
+#endif // MOZ_ENABLE_PROFILER_SPS
+
     SOCKET_LOG(("STS thread init %d sockets\n", gMaxCount));
 
     psm::InitializeSSLServerCertVerificationThreads();
 
     gSocketThread = PR_GetCurrentThread();
 
     {
         MutexAutoLock lock(mLock);
@@ -999,16 +1004,21 @@ nsSocketTransportService::Run()
     // socket detach handlers get processed.
     NS_ProcessPendingEvents(mRawThread);
 
     gSocketThread = nullptr;
 
     psm::StopSSLServerCertVerificationThreads();
 
     SOCKET_LOG(("STS thread exit\n"));
+
+#ifdef MOZ_ENABLE_PROFILER_SPS
+    profiler_unregister_thread();
+#endif // MOZ_ENABLE_PROFILER_SPS
+
     return NS_OK;
 }
 
 void
 nsSocketTransportService::DetachSocketWithGuard(bool aGuardLocals,
                                                 SocketContext *socketList,
                                                 int32_t index)
 {