Bug 1948111 - Don't re-initialize IndexedDatabaseManager::mLocale; r=dom-storage-reviewers,asuth, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D238593
This commit is contained in:
Jan Varga 2025-02-20 08:35:22 +00:00
parent 144f5c3184
commit 558ef1b0e2
2 changed files with 11 additions and 2 deletions

View file

@ -215,7 +215,8 @@ auto DatabaseFilePathMatchPredicate(const nsAString* const aDatabaseFilePath) {
} // namespace
IndexedDatabaseManager::IndexedDatabaseManager() : mBackgroundActor(nullptr) {
IndexedDatabaseManager::IndexedDatabaseManager()
: mLocaleInitialized(false), mBackgroundActor(nullptr) {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
}
@ -677,7 +678,11 @@ void IndexedDatabaseManager::LoggingModePrefChangedCallback(
}
nsresult IndexedDatabaseManager::EnsureLocale() {
MOZ_ASSERT(NS_IsMainThread());
AssertIsOnMainThread();
if (mLocaleInitialized) {
return NS_OK;
}
nsAutoCString acceptLang;
Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);
@ -698,6 +703,8 @@ nsresult IndexedDatabaseManager::EnsureLocale() {
mLocale.AssignLiteral("en_US");
}
mLocaleInitialized = true;
return NS_OK;
}

View file

@ -8,6 +8,7 @@
#define mozilla_dom_indexeddatabasemanager_h__
#include "js/TypeDecls.h"
#include "MainThreadUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/dom/quota/PersistenceType.h"
#include "mozilla/Logging.h"
@ -159,6 +160,7 @@ class IndexedDatabaseManager final {
mPendingDeleteInfos;
nsCString mLocale;
bool mLocaleInitialized MOZ_GUARDED_BY(sMainThreadCapability);
indexedDB::BackgroundUtilsChild* mBackgroundActor;