refactor: use base::NoDestructor instead of base::LazyInstance (#40947)
* refactor: use NoDestructor for g_io_thread_application_locale * refactor: use NoDestructor for ExtensionActionAPI::GetFactoryInstance() * refactor: use NoDestructor for ElectronExtensionsClient::GetPermissionMessageProvider() * refactor: use NoDestructor for feat_add_support_for_overriding_the_base_spellchecker_download_url.patch * chore: remove unused #include * fixup! refactor: use NoDestructor for ElectronExtensionsClient::GetPermissionMessageProvider() make sure instance is static * chore: remove unused #include "base/lazy_instance.h"
This commit is contained in:
parent
57b29903e3
commit
80b220d214
6 changed files with 28 additions and 27 deletions
|
@ -17,7 +17,6 @@
|
|||
#include "base/environment.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/stl_util.h"
|
||||
|
@ -226,14 +225,13 @@ namespace {
|
|||
|
||||
ElectronBrowserClient* g_browser_client = nullptr;
|
||||
|
||||
base::LazyInstance<std::string>::DestructorAtExit
|
||||
g_io_thread_application_locale = LAZY_INSTANCE_INITIALIZER;
|
||||
base::NoDestructor<std::string> g_io_thread_application_locale;
|
||||
|
||||
base::NoDestructor<std::string> g_application_locale;
|
||||
|
||||
void SetApplicationLocaleOnIOThread(const std::string& locale) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
g_io_thread_application_locale.Get() = locale;
|
||||
*g_io_thread_application_locale = locale;
|
||||
}
|
||||
|
||||
void BindNetworkHintsHandler(
|
||||
|
@ -342,7 +340,7 @@ void ElectronBrowserClient::SetApplicationLocale(const std::string& locale) {
|
|||
if (!BrowserThread::IsThreadInitialized(BrowserThread::IO) ||
|
||||
!content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE, base::BindOnce(&SetApplicationLocaleOnIOThread, locale))) {
|
||||
g_io_thread_application_locale.Get() = locale;
|
||||
*g_io_thread_application_locale = locale;
|
||||
}
|
||||
*g_application_locale = locale;
|
||||
}
|
||||
|
@ -1517,9 +1515,9 @@ void ElectronBrowserClient::
|
|||
}
|
||||
|
||||
std::string ElectronBrowserClient::GetApplicationLocale() {
|
||||
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
|
||||
return g_io_thread_application_locale.Get();
|
||||
return *g_application_locale;
|
||||
return BrowserThread::CurrentlyOn(BrowserThread::IO)
|
||||
? *g_io_thread_application_locale
|
||||
: *g_application_locale;
|
||||
}
|
||||
|
||||
bool ElectronBrowserClient::ShouldEnableStrictSiteIsolation() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue