Bug 1380096 - Don't require that sMainThreadRunnableName is null-terminated, r=erahm

MozReview-Commit-ID: 9Zo1vjmKzZC
This commit is contained in:
Michael Layzell
2017-07-11 16:52:09 -04:00
parent bd45b21f8e
commit cd8964a17f
3 changed files with 13 additions and 10 deletions

View File

@@ -99,7 +99,7 @@ static LazyLogModule sThreadLog("nsThread");
NS_DECL_CI_INTERFACE_GETTER(nsThread)
const char* nsThread::sMainThreadRunnableName = nullptr;
const nsACString* nsThread::sMainThreadRunnableName = nullptr;
//-----------------------------------------------------------------------------
// Because we do not have our own nsIFactory, we have to implement nsIClassInfo
@@ -1422,15 +1422,17 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult)
// If we're on the main thread, we want to record our current runnable's
// name in a static so that BHR can record it.
const char* restoreRunnableName = nullptr;
const nsACString* restoreRunnableName = nullptr;
auto clear = MakeScopeExit([&] {
if (MAIN_THREAD == mIsMainThread) {
MOZ_ASSERT(NS_IsMainThread());
sMainThreadRunnableName = restoreRunnableName;
}
});
if (MAIN_THREAD == mIsMainThread) {
MOZ_ASSERT(NS_IsMainThread());
restoreRunnableName = sMainThreadRunnableName;
sMainThreadRunnableName = name.get();
sMainThreadRunnableName = &name;
}
#endif