Bug 1323100 - Assign names to all remaining threads that are created through NS_NewThread and create them using NS_NewNamedThread instead. r=froydnj

MozReview-Commit-ID: 7W1dt2BBKJZ

--HG--
extra : rebase_source : c7e335dac2e0f02782f0eb229a7181c8d01317a2
This commit is contained in:
Markus Stange 2016-12-21 11:43:50 +01:00
Родитель 21cbfb0bb4
Коммит 692210bd80
25 изменённых файлов: 84 добавлений и 65 удалений

Просмотреть файл

@ -541,8 +541,9 @@ DarwinGamepadService::StartupInternal()
void DarwinGamepadService::Startup()
{
Unused << NS_NewThread(getter_AddRefs(mMonitorThread),
new DarwinGamepadServiceStartupRunnable(this));
Unused << NS_NewNamedThread("Gamepad",
getter_AddRefs(mMonitorThread),
new DarwinGamepadServiceStartupRunnable(this));
}
void DarwinGamepadService::Shutdown()

Просмотреть файл

@ -1073,7 +1073,7 @@ StartGamepadMonitoring()
return;
}
sIsShutdown = false;
NS_NewThread(getter_AddRefs(gMonitorThread));
NS_NewNamedThread("Gamepad", getter_AddRefs(gMonitorThread));
gMonitorThread->Dispatch(new StartWindowsGamepadServiceRunnable(),
NS_DISPATCH_NORMAL);
}

Просмотреть файл

@ -22,9 +22,10 @@ nsresult FileBlockCache::Open(PRFileDesc* aFD)
}
{
MonitorAutoLock mon(mDataMonitor);
nsresult res = NS_NewThread(getter_AddRefs(mThread),
nullptr,
SharedThreadPool::kStackSize);
nsresult res = NS_NewNamedThread("FileBlockCache",
getter_AddRefs(mThread),
nullptr,
SharedThreadPool::kStackSize);
mIsOpen = NS_SUCCEEDED(res);
return res;
}

Просмотреть файл

@ -375,7 +375,7 @@ ResourceSocketListener::OnSocketAccepted(nsIServerSocket* aServ,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewThread(getter_AddRefs(thread));
rv = NS_NewNamedThread("ServeResource", getter_AddRefs(thread));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRunnable> event = new ServeResourceEvent(input.get(), output.get(), mServer);

Просмотреть файл

@ -44,7 +44,7 @@ public:
void Init() {
nsCOMPtr<nsIThread> thread;
nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &TestBinding::ReadMetadata);
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
nsresult rv = NS_NewNamedThread("ReadMetadata", getter_AddRefs(thread), r);
EXPECT_EQ(NS_OK, rv);
thread->Shutdown();
}

Просмотреть файл

@ -556,7 +556,7 @@ GonkGPSGeolocationProvider::Startup()
}
if (!mInitThread) {
nsresult rv = NS_NewThread(getter_AddRefs(mInitThread));
nsresult rv = NS_NewNamedThread("Gonk GPS", getter_AddRefs(mInitThread));
NS_ENSURE_SUCCESS(rv, rv);
}

Просмотреть файл

@ -1569,7 +1569,7 @@ LayerScopeWebSocketManager::SocketHandler::CloseConnection()
LayerScopeWebSocketManager::LayerScopeWebSocketManager()
: mHandlerMutex("LayerScopeWebSocketManager::mHandlerMutex")
{
NS_NewThread(getter_AddRefs(mDebugSenderThread));
NS_NewNamedThread("LayerScope", getter_AddRefs(mDebugSenderThread));
mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID);
int port = gfxPrefs::LayerScopePort();

Просмотреть файл

@ -395,7 +395,7 @@ EnsureVibratorThreadInitialized()
sVibratorRunnable = new VibratorRunnable();
nsCOMPtr<nsIThread> thread;
NS_NewThread(getter_AddRefs(thread), sVibratorRunnable);
NS_NewNamedThread("Gonk Vibrator", getter_AddRefs(thread), sVibratorRunnable);
}
} // namespace

Просмотреть файл

@ -69,7 +69,8 @@ RunDecodeToSurface(const ImageTestCase& aTestCase)
ASSERT_TRUE(inputStream != nullptr);
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), nullptr);
nsresult rv =
NS_NewNamedThread("DecodeToSurface", getter_AddRefs(thread), nullptr);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// We run the DecodeToSurface tests off-main-thread to ensure that

Просмотреть файл

@ -152,7 +152,7 @@ BackgroundFileSaver::Init()
rv = NS_GetCurrentThread(getter_AddRefs(mControlThread));
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewThread(getter_AddRefs(mWorkerThread));
rv = NS_NewNamedThread("BgFileSaver", getter_AddRefs(mWorkerThread));
NS_ENSURE_SUCCESS(rv, rv);
sThreadCount++;

Просмотреть файл

@ -2326,8 +2326,9 @@ DataChannelConnection::SendBlob(uint16_t stream, nsIInputStream *aBlob)
NS_ENSURE_TRUE(channel, 0);
// Spawn a thread to send the data
if (!mInternalIOThread) {
nsresult res = NS_NewThread(getter_AddRefs(mInternalIOThread));
if (NS_FAILED(res)) {
nsresult rv = NS_NewNamedThread("DataChannel IO",
getter_AddRefs(mInternalIOThread));
if (NS_FAILED(rv)) {
return -1;
}
}

Просмотреть файл

@ -315,7 +315,7 @@ NS_IMPL_ISUPPORTS(FileChannelWorker, nsIRunnable)
////////////////////////////////////////////////////////////////////////////////
void
Test(CreateFun create, uint32_t count,
Test(CreateFun create, const char* name, uint32_t count,
nsIFile* inDirSpec, nsIFile* outDirSpec, uint32_t bufSize)
{
nsresult rv;
@ -375,7 +375,8 @@ Test(CreateFun create, uint32_t count,
bufSize);
if (NS_FAILED(rv)) goto done;
rv = NS_NewThread(getter_AddRefs(thread), worker, 0, PR_JOINABLE_THREAD);
rv = NS_NewNamedThread(name, getter_AddRefs(thread),
worker, 0, PR_JOINABLE_THREAD);
if (NS_FAILED(rv)) goto done;
bool inserted = threads.InsertObjectAt(thread, i);
@ -433,42 +434,44 @@ main(int argc, char* argv[])
if (NS_FAILED(rv)) return rv;
CreateFun create = FileChannelWorker::Create;
const char* name = "FileChannelWorker";
Test(create, 1, inDirFile, outDirFile, 16 * 1024);
#if 1
printf("FileChannelWorker *****************************\n");
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
#endif
create = FileSpecWorker::Create;
name = "FileSpecWorker";
printf("FileSpecWorker ********************************\n");
#if 1
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
#endif
#if 1
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
#endif
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM

Просмотреть файл

@ -46,7 +46,7 @@ TEST(storage_service_init_background_thread_DeathTest, Test)
do_check_true(event);
nsCOMPtr<nsIThread> thread;
do_check_success(NS_NewThread(getter_AddRefs(thread)));
do_check_success(NS_NewNamedThread("StorageService", getter_AddRefs(thread)));
do_check_success(thread->Dispatch(event, NS_DISPATCH_NORMAL));

Просмотреть файл

@ -14,7 +14,8 @@ template<typename Function>
void RunTestInNewThread(Function&& aFunction) {
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(mozilla::Forward<Function>(aFunction));
nsCOMPtr<nsIThread> testingThread;
nsresult rv = NS_NewThread(getter_AddRefs(testingThread), r);
nsresult rv =
NS_NewNamedThread("Testing Thread", getter_AddRefs(testingThread), r);
ASSERT_EQ(rv, NS_OK);
testingThread->Shutdown();
}

Просмотреть файл

@ -3609,7 +3609,7 @@ InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb)
OOPInit();
if (!sInjectorThread) {
if (NS_FAILED(NS_NewThread(&sInjectorThread)))
if (NS_FAILED(NS_NewNamedThread("CrashRep Inject", &sInjectorThread)))
return;
}

Просмотреть файл

@ -205,7 +205,8 @@ IdentityCryptoService::GenerateKeyPair(
nsCOMPtr<nsIRunnable> r = new KeyGenRunnable(keyType, callback);
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
nsresult rv = NS_NewNamedThread("GenerateKeyPair", getter_AddRefs(thread),
r);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -309,7 +310,7 @@ KeyPair::Sign(const nsACString & textToSign,
callback);
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
nsresult rv = NS_NewNamedThread("KeyPair Sign", getter_AddRefs(thread), r);
return rv;
}

Просмотреть файл

@ -1246,7 +1246,8 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
MOZ_ASSERT(NS_IsMainThread(), "not main thread");
nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate);
return NS_NewThread(getter_AddRefs(mProcessWatcher), r);
return NS_NewNamedThread("Update Watcher", getter_AddRefs(mProcessWatcher),
r);
}

Просмотреть файл

@ -151,7 +151,7 @@ void LSPAnnotate()
nsCOMPtr<nsIThread> thread;
nsCOMPtr<nsIRunnable> runnable =
do_QueryObject(new LSPAnnotationGatherer());
NS_NewThread(getter_AddRefs(thread), runnable);
NS_NewNamedThread("LSP Annotate", getter_AddRefs(thread), runnable);
}
} // namespace crashreporter

Просмотреть файл

@ -241,7 +241,9 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
return NS_OK;
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(this, aSoundAlias);
NS_ENSURE_TRUE(player, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = NS_NewThread(getter_AddRefs(mPlayerThread), player);
nsresult rv =
NS_NewNamedThread("PlaySystemSound", getter_AddRefs(mPlayerThread),
player);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -299,7 +301,8 @@ NS_IMETHODIMP nsSound::PlayEventSound(uint32_t aEventId)
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(this, sound);
NS_ENSURE_TRUE(player, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = NS_NewThread(getter_AddRefs(mPlayerThread), player);
nsresult rv =
NS_NewNamedThread("PlayEventSound", getter_AddRefs(mPlayerThread), player);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}

Просмотреть файл

@ -107,7 +107,7 @@ TestPipe(nsIInputStream* in, nsIOutputStream* out)
nsresult rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewThread(getter_AddRefs(thread), receiver);
rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
if (NS_FAILED(rv)) return rv;
uint32_t total = 0;
@ -225,7 +225,8 @@ TestShortWrites(nsIInputStream* in, nsIOutputStream* out)
nsresult rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewThread(getter_AddRefs(thread), receiver);
rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread),
receiver);
if (NS_FAILED(rv)) return rv;
uint32_t total = 0;
@ -330,14 +331,15 @@ TEST(Pipes, ChainedPipes)
if (pump == nullptr) return;
nsCOMPtr<nsIThread> thread;
rv = NS_NewThread(getter_AddRefs(thread), pump);
rv = NS_NewNamedThread("ChainedPipePump", getter_AddRefs(thread), pump);
if (NS_FAILED(rv)) return;
RefPtr<nsReceiver> receiver = new nsReceiver(in2);
if (receiver == nullptr) return;
nsCOMPtr<nsIThread> receiverThread;
rv = NS_NewThread(getter_AddRefs(receiverThread), receiver);
rv = NS_NewNamedThread("ChainedPipeRecv", getter_AddRefs(receiverThread),
receiver);
if (NS_FAILED(rv)) return;
uint32_t total = 0;

Просмотреть файл

@ -255,7 +255,7 @@ TEST(RacingServiceManager, Test)
// Run the classID test
nsCOMPtr<nsIThread> newThread;
rv = NS_NewThread(getter_AddRefs(newThread), runnable);
rv = NS_NewNamedThread("RacingServMan", getter_AddRefs(newThread), runnable);
ASSERT_TRUE(NS_SUCCEEDED(rv));
{

Просмотреть файл

@ -49,7 +49,7 @@ TEST(Threads, Main)
EXPECT_TRUE(event);
nsCOMPtr<nsIThread> runner;
rv = NS_NewThread(getter_AddRefs(runner), event);
rv = NS_NewNamedThread("TestThreadsMain", getter_AddRefs(runner), event);
EXPECT_TRUE(NS_SUCCEEDED(rv));
nsCOMPtr<nsIThread> thread;
@ -112,7 +112,8 @@ TEST(Threads, Stress)
for (k = 0; k < threads; k++) {
nsCOMPtr<nsIThread> t;
nsresult rv = NS_NewThread(getter_AddRefs(t), new nsStressRunner(k));
nsresult rv = NS_NewNamedThread("StressRunner", getter_AddRefs(t),
new nsStressRunner(k));
EXPECT_TRUE(NS_SUCCEEDED(rv));
NS_ADDREF(array[k] = t);
}
@ -169,7 +170,8 @@ public:
{
mozilla::MonitorAutoLock lock(*gBeginAsyncShutdownMonitor);
rv = NS_NewThread(getter_AddRefs(t), new AsyncShutdownPreparer());
rv = NS_NewNamedThread("AsyncShutdownPr", getter_AddRefs(t),
new AsyncShutdownPreparer());
EXPECT_TRUE(NS_SUCCEEDED(rv));
lock.Wait();
@ -221,7 +223,8 @@ TEST(Threads, AsyncShutdown)
{
mozilla::MonitorAutoLock lock(*gAsyncShutdownReadyMonitor);
rv = NS_NewThread(getter_AddRefs(t), new AsyncShutdownWaiter());
rv = NS_NewNamedThread("AsyncShutdownWt", getter_AddRefs(t),
new AsyncShutdownWaiter());
EXPECT_TRUE(NS_SUCCEEDED(rv));
lock.Wait();

Просмотреть файл

@ -31,7 +31,7 @@ class AutoTestThread
public:
AutoTestThread() {
nsCOMPtr<nsIThread> newThread;
nsresult rv = NS_NewThread(getter_AddRefs(newThread));
nsresult rv = NS_NewNamedThread("AutoTestThread", getter_AddRefs(newThread));
if (NS_FAILED(rv))
return;

Просмотреть файл

@ -169,7 +169,7 @@ LazyIdleThread::EnsureThread()
return NS_ERROR_UNEXPECTED;
}
rv = NS_NewThread(getter_AddRefs(mThread), runnable);
rv = NS_NewNamedThread("Lazy Idle", getter_AddRefs(mThread), runnable);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -323,7 +323,8 @@ TimerThread::Init()
if (mInitInProgress.exchange(true) == false) {
// We hold on to mThread to keep the thread alive.
nsresult rv = NS_NewThread(getter_AddRefs(mThread), this);
nsresult rv =
NS_NewNamedThread("Timer Thread", getter_AddRefs(mThread), this);
if (NS_FAILED(rv)) {
mThread = nullptr;
} else {