Bug 1323100 - Use NS_NewNamedThread for IndexedDB threads. r?froydnj
MozReview-Commit-ID: Do4l5QL2qSG
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5715,16 +5715,21 @@ public:
NS_DECL_ISUPPORTS_INHERITED
uint32_t
SerialNumber() const
{
return mSerialNumber;
}
+ nsCString GetThreadName() const
+ {
+ return nsPrintfCString("IndexedDB #%lu", mSerialNumber);
+ }
+
private:
~ThreadRunnable() override;
NS_DECL_NSIRUNNABLE
};
class ConnectionPool::TransactionInfo final
{
@@ -12566,17 +12571,20 @@ ConnectionPool::ScheduleTransaction(Tran
if (mIdleThreads.IsEmpty()) {
bool created = false;
if (mTotalThreadCount < kMaxConnectionThreadCount) {
// This will set the thread up with the profiler.
RefPtr<ThreadRunnable> runnable = new ThreadRunnable();
nsCOMPtr<nsIThread> newThread;
- if (NS_SUCCEEDED(NS_NewThread(getter_AddRefs(newThread), runnable))) {
+ nsresult rv =
+ NS_NewNamedThread(runnable->GetThreadName(),
+ getter_AddRefs(newThread), runnable);
+ if (NS_SUCCEEDED(rv)) {
MOZ_ASSERT(newThread);
IDB_DEBUG_LOG(("ConnectionPool created thread %lu",
runnable->SerialNumber()));
dbInfo->mThreadInfo.mThread.swap(newThread);
dbInfo->mThreadInfo.mRunnable.swap(runnable);
@@ -13279,43 +13287,27 @@ ThreadRunnable::~ThreadRunnable()
}
NS_IMPL_ISUPPORTS_INHERITED0(ConnectionPool::ThreadRunnable, Runnable)
nsresult
ConnectionPool::
ThreadRunnable::Run()
{
-#ifdef MOZ_ENABLE_PROFILER_SPS
- char stackTopGuess;
-#endif // MOZ_ENABLE_PROFILER_SPS
-
MOZ_ASSERT(!IsOnBackgroundThread());
MOZ_ASSERT(mContinueRunning);
if (!mFirstRun) {
mContinueRunning = false;
return NS_OK;
}
mFirstRun = false;
{
- // Scope for the thread name. Both PR_SetCurrentThreadName() and
- // profiler_register_thread() copy the string so we don't need to keep it.
- const nsPrintfCString threadName("IndexedDB #%lu", mSerialNumber);
-
- PR_SetCurrentThreadName(threadName.get());
-
-#ifdef MOZ_ENABLE_PROFILER_SPS
- profiler_register_thread(threadName.get(), &stackTopGuess);
-#endif // MOZ_ENABLE_PROFILER_SPS
- }
-
- {
// Scope for the profiler label.
PROFILER_LABEL("IndexedDB",
"ConnectionPool::ThreadRunnable::Run",
js::ProfileEntry::Category::STORAGE);
nsIThread* currentThread = NS_GetCurrentThread();
MOZ_ASSERT(currentThread);
@@ -13346,20 +13338,16 @@ ThreadRunnable::Run()
MOZ_ALWAYS_TRUE(
PR_Sleep(PR_MillisecondsToInterval(kDEBUGTransactionThreadSleepMS)) ==
PR_SUCCESS);
}
#endif // DEBUG
}
}
-#ifdef MOZ_ENABLE_PROFILER_SPS
- profiler_unregister_thread();
-#endif // MOZ_ENABLE_PROFILER_SPS
-
return NS_OK;
}
ConnectionPool::
ThreadInfo::ThreadInfo()
{
AssertIsOnBackgroundThread();