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() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "extensions/browser/event_router.h"
|
||||
#include "extensions/browser/extension_prefs.h"
|
||||
|
@ -38,9 +38,6 @@ ExtensionActionAPI::Observer::~Observer() {}
|
|||
// ExtensionActionAPI
|
||||
//
|
||||
|
||||
static base::LazyInstance<BrowserContextKeyedAPIFactory<ExtensionActionAPI>>::
|
||||
DestructorAtExit g_extension_action_api_factory = LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
ExtensionActionAPI::ExtensionActionAPI(content::BrowserContext* context)
|
||||
: browser_context_(context), extension_prefs_(nullptr) {}
|
||||
|
||||
|
@ -49,7 +46,9 @@ ExtensionActionAPI::~ExtensionActionAPI() {}
|
|||
// static
|
||||
BrowserContextKeyedAPIFactory<ExtensionActionAPI>*
|
||||
ExtensionActionAPI::GetFactoryInstance() {
|
||||
return g_extension_action_api_factory.Pointer();
|
||||
static base::NoDestructor<BrowserContextKeyedAPIFactory<ExtensionActionAPI>>
|
||||
instance;
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "extensions/browser/media_capture_util.h"
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue