Bug 1320289 - register STS thread to gecko profiler. r=mayhemer,cyu draft
authorShih-Chiang Chien <schien@mozilla.com>
Fri, 25 Nov 2016 18:07:06 +0800
changeset 443893 e28286c9694cf9dc49876075875db0614997248d
parent 443220 34fce7c12173bdd6dda54c2ebf6d344252f1ac48
child 538181 fc6a3d6f0f0b84bd4b58a6b44ae440f29377271b
push id37134
push userschien@mozilla.com
push dateFri, 25 Nov 2016 11:09:28 +0000
reviewersmayhemer, cyu
bugs1320289
milestone53.0a1
Bug 1320289 - register STS thread to gecko profiler. r=mayhemer,cyu 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)
 {