Bug 1388464: Use SyncRunnable instead of DISPATCH_SYNC to actually block the main thread during the blocking preference file write. r=smaug

MozReview-Commit-ID: 6J1252Q3pBr

--HG--
extra : rebase_source : a2ede1a9e5a9cf6f26139c747404f6a62318207e
This commit is contained in:
Milan Sreckovic 2017-08-08 17:14:28 -04:00
parent d408f82c90
commit 90d1627382

View File

@ -11,6 +11,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h"
#include "mozilla/UniquePtrExtensions.h"
@ -1239,9 +1240,13 @@ Preferences::WritePrefFile(nsIFile* aFile, SaveMethod aSaveMethod)
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
bool async = aSaveMethod == SaveMethod::Asynchronous;
rv = target->Dispatch(new PWRunnable(aFile),
async ? nsIEventTarget::DISPATCH_NORMAL :
nsIEventTarget::DISPATCH_SYNC);
if (async) {
rv = target->Dispatch(new PWRunnable(aFile),
nsIEventTarget::DISPATCH_NORMAL);
} else {
// Note that we don't get the nsresult return value here
SyncRunnable::DispatchToThread(target, new PWRunnable(aFile), true);
}
return rv;
}
}