Bug 1271402: name and cleanup DataStorage thread when running XPCshell r=froyd,dkeeler

MozReview-Commit-ID: 2brXgEcp91J
This commit is contained in:
Randell Jesup 2016-05-11 00:11:40 -04:00
Родитель 477adfcd7e
Коммит 73a32768d1
2 изменённых файлов: 9 добавлений и 7 удалений

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

@ -550,7 +550,7 @@ nsSocketTransportService::Init()
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), this);
nsresult rv = NS_NewNamedThread("Socket Thread", getter_AddRefs(thread), this);
if (NS_FAILED(rv)) return rv;
{
@ -820,8 +820,6 @@ nsSocketTransportService::MarkTheLastElementOfPendingQueue()
NS_IMETHODIMP
nsSocketTransportService::Run()
{
PR_SetCurrentThreadName("Socket Thread");
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
NuwaMarkCurrentThread(nullptr, nullptr);

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

@ -106,7 +106,7 @@ DataStorage::Init(bool& aDataWillPersist)
nsresult rv;
if (XRE_IsParentProcess()) {
rv = NS_NewThread(getter_AddRefs(mWorkerThread));
rv = NS_NewNamedThread("DataStorage", getter_AddRefs(mWorkerThread));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -148,9 +148,10 @@ DataStorage::Init(bool& aDataWillPersist)
// dispatched, so we need to clean up on xpcom-shutdown.
if (XRE_IsParentProcess()) {
os->AddObserver(this, "profile-before-change", false);
} else {
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
}
// In the Parent process, this is a backstop for xpcshell and other cases
// where profile-before-change might not get sent.
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
// For test purposes, we can set the write timer to be very fast.
mTimerDelay = Preferences::GetInt("test.datastorage.write_timer_ms",
@ -864,8 +865,11 @@ DataStorage::Observe(nsISupports* aSubject, const char* aTopic,
if (strcmp(aTopic, "last-pb-context-exited") == 0) {
MutexAutoLock lock(mMutex);
mPrivateDataTable.Clear();
} else if (strcmp(aTopic, "profile-before-change") == 0) {
} else if (strcmp(aTopic, "profile-before-change") == 0 ||
(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0 &&
XRE_IsParentProcess())) {
MOZ_ASSERT(XRE_IsParentProcess());
// per bug 1271402, this should be safe to run multiple times
{
MutexAutoLock lock(mMutex);
rv = AsyncWriteData(lock);