diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/indexedDB/IndexedDatabaseManager.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/IndexedDatabaseManager.cpp')
-rw-r--r-- | dom/indexedDB/IndexedDatabaseManager.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 5ee16ec5e9..0558c38826 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -296,25 +296,6 @@ nsresult IndexedDatabaseManager::Init() { Preferences::RegisterCallbackAndCall(MaxPreloadExtraRecordsPrefChangeCallback, kPrefMaxPreloadExtraRecords); - nsAutoCString acceptLang; - Preferences::GetLocalizedCString("intl.accept_languages", acceptLang); - - // Split values on commas. - for (const auto& lang : - nsCCharSeparatedTokenizer(acceptLang, ',').ToRange()) { - mozilla::intl::LocaleCanonicalizer::Vector asciiString{}; - auto result = mozilla::intl::LocaleCanonicalizer::CanonicalizeICULevel1( - PromiseFlatCString(lang).get(), asciiString); - if (result.isOk()) { - mLocale.AssignASCII(asciiString); - break; - } - } - - if (mLocale.IsEmpty()) { - mLocale.AssignLiteral("en_US"); - } - return NS_OK; } @@ -652,11 +633,37 @@ void IndexedDatabaseManager::LoggingModePrefChangedCallback( } } +nsresult IndexedDatabaseManager::EnsureLocale() { + MOZ_ASSERT(NS_IsMainThread()); + + nsAutoCString acceptLang; + Preferences::GetLocalizedCString("intl.accept_languages", acceptLang); + + // Split values on commas. + for (const auto& lang : + nsCCharSeparatedTokenizer(acceptLang, ',').ToRange()) { + mozilla::intl::LocaleCanonicalizer::Vector asciiString{}; + auto result = mozilla::intl::LocaleCanonicalizer::CanonicalizeICULevel1( + PromiseFlatCString(lang).get(), asciiString); + if (result.isOk()) { + mLocale.AssignASCII(asciiString); + break; + } + } + + if (mLocale.IsEmpty()) { + mLocale.AssignLiteral("en_US"); + } + + return NS_OK; +} + // static const nsCString& IndexedDatabaseManager::GetLocale() { IndexedDatabaseManager* idbManager = Get(); MOZ_ASSERT(idbManager, "IDBManager is not ready!"); + MOZ_ASSERT(!idbManager->mLocale.IsEmpty()); return idbManager->mLocale; } |