Bug 789945: Part 4. Explicitly make some pref save be blocking calls. r=bsmedberg

MozReview-Commit-ID: 1MEp7o65HAV

--HG--
extra : rebase_source : b787c78253ad22b6fd4785e7a66f426af4f9b424
This commit is contained in:
Milan Sreckovic 2017-06-14 13:38:17 -04:00
Родитель d43b8012f4
Коммит 8a9d97395a
6 изменённых файлов: 16 добавлений и 7 удалений

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

@ -388,7 +388,7 @@ DriverCrashGuard::FlushPreferences()
MOZ_ASSERT(XRE_IsParentProcess());
if (nsIPrefService* prefService = Preferences::GetService()) {
prefService->SavePrefFile(nullptr);
static_cast<Preferences *>(prefService)->SavePrefFileBlocking();
}
}

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

@ -20,6 +20,8 @@
* - Computed values (e.g. 50 * 1024) don't work.
*/
pref("preferences.allow.omt-write", true);
pref("keyword.enabled", false);
pref("general.useragent.locale", "chrome://global/locale/intl.properties");
pref("general.useragent.compatMode.firefox", false);

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

@ -812,7 +812,7 @@ Database::ForceCrashAndReplaceDatabase(const nsCString& aReason)
Preferences::SetBool(PREF_FORCE_DATABASE_REPLACEMENT, true);
// Ensure that prefs get saved, or we could crash before storing them.
nsIPrefService* prefService = Preferences::GetService();
if (prefService && NS_SUCCEEDED(prefService->SavePrefFile(nullptr))) {
if (prefService && NS_SUCCEEDED(static_cast<Preferences *>(prefService)->SavePrefFileBlocking())) {
// We could force an application restart here, but we'd like to get these
// cases reported to us, so let's force a crash instead.
MOZ_CRASH_UNSAFE_OOL(aReason.get());

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

@ -914,7 +914,7 @@ nsAppStartup::TrackStartupCrashBegin(bool *aIsSafeModeNecessary)
mIsSafeModeNecessary = (recentCrashes > maxResumedCrashes && maxResumedCrashes != -1);
nsCOMPtr<nsIPrefService> prefs = Preferences::GetService();
rv = prefs->SavePrefFile(nullptr); // flush prefs to disk since we are tracking crashes
rv = static_cast<Preferences *>(prefs.get())->SavePrefFileBlocking(); // flush prefs to disk since we are tracking crashes
NS_ENSURE_SUCCESS(rv, rv);
GetAutomaticSafeModeNecessary(aIsSafeModeNecessary);
@ -974,7 +974,10 @@ nsAppStartup::TrackStartupCrashEnd()
if (NS_FAILED(rv)) NS_WARNING("Could not clear startup crash count.");
}
nsCOMPtr<nsIPrefService> prefs = Preferences::GetService();
rv = prefs->SavePrefFile(nullptr); // flush prefs to disk since we are tracking crashes
// save prefs to disk since we are tracking crashes. This may be
// asynchronous, so a crash could sneak in that we would mistake for
// a start up crash. See bug 789945 and bug 1361262.
rv = prefs->SavePrefFile(nullptr);
return rv;
}

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

@ -773,7 +773,10 @@ CreateContentProcessSandboxTempDir()
nsCOMPtr<nsIPrefService> prefsvc = Preferences::GetService();
if (!prefsvc || NS_FAILED((rv = prefsvc->SavePrefFile(nullptr)))) {
// Again, if we fail to save the pref file we might not be able to clean
// up the temp directory, so don't create one.
// up the temp directory, so don't create one. Note that in the case
// the preference values allows an off main thread save, the successful
// return from the call doesn't mean we actually saved the file. See
// bug 1364496 for details.
NS_WARNING("Failed to save pref file, cannot create temp dir.");
return nullptr;
}

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

@ -194,9 +194,10 @@ public:
// We really want to send a notification like profile-before-change,
// but profile-before-change ends up shutting some things down instead
// of flushing data
nsIPrefService* prefs = Preferences::GetService();
Preferences* prefs = static_cast<Preferences *>(Preferences::GetService());
if (prefs) {
prefs->SavePrefFile(nullptr);
// Force a main thread blocking save
prefs->SavePrefFileBlocking();
}
}