diff --git chrome/browser/spellchecker/spellcheck_factory.cc chrome/browser/spellchecker/spellcheck_factory.cc index 64b5243d510a..8ae3001f85fc 100644 --- chrome/browser/spellchecker/spellcheck_factory.cc +++ chrome/browser/spellchecker/spellcheck_factory.cc @@ -17,6 +17,13 @@ #include "services/service_manager/public/cpp/identity.h" #include "ui/base/l10n/l10n_util.h" +namespace { + +static base::LazyInstance::Leaky + g_spellcheck_service_factory = LAZY_INSTANCE_INITIALIZER; + +} // namespace + // static SpellcheckService* SpellcheckServiceFactory::GetForContext( content::BrowserContext* context) { @@ -37,7 +44,7 @@ SpellcheckService* SpellcheckServiceFactory::GetForRenderer( // static SpellcheckServiceFactory* SpellcheckServiceFactory::GetInstance() { - return base::Singleton::get(); + return g_spellcheck_service_factory.Pointer(); } SpellcheckServiceFactory::SpellcheckServiceFactory() diff --git chrome/browser/spellchecker/spellcheck_factory.h chrome/browser/spellchecker/spellcheck_factory.h index fd4e6643725c..fcdbb8e4db88 100644 --- chrome/browser/spellchecker/spellcheck_factory.h +++ chrome/browser/spellchecker/spellcheck_factory.h @@ -7,7 +7,7 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/singleton.h" +#include "base/lazy_instance.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" class SpellcheckService; @@ -31,7 +31,7 @@ class SpellcheckServiceFactory : public BrowserContextKeyedServiceFactory { static SpellcheckServiceFactory* GetInstance(); private: - friend struct base::DefaultSingletonTraits; + friend struct base::LazyInstanceTraitsBase; SpellcheckServiceFactory(); ~SpellcheckServiceFactory() override; diff --git chrome/browser/supervised_user/supervised_user_settings_service_factory.cc chrome/browser/supervised_user/supervised_user_settings_service_factory.cc index 173ac3132161..473e56161cca 100644 --- chrome/browser/supervised_user/supervised_user_settings_service_factory.cc +++ chrome/browser/supervised_user/supervised_user_settings_service_factory.cc @@ -9,6 +9,13 @@ #include "chrome/browser/supervised_user/supervised_user_settings_service.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" +namespace { + +base::LazyInstance::Leaky + g_service_factory = LAZY_INSTANCE_INITIALIZER; + +} // namespace + // static SupervisedUserSettingsService* SupervisedUserSettingsServiceFactory::GetForProfile(Profile* profile) { @@ -19,7 +26,7 @@ SupervisedUserSettingsServiceFactory::GetForProfile(Profile* profile) { // static SupervisedUserSettingsServiceFactory* SupervisedUserSettingsServiceFactory::GetInstance() { - return base::Singleton::get(); + return g_service_factory.Pointer(); } SupervisedUserSettingsServiceFactory::SupervisedUserSettingsServiceFactory() diff --git chrome/browser/supervised_user/supervised_user_settings_service_factory.h chrome/browser/supervised_user/supervised_user_settings_service_factory.h index 2907619549ba..f941fba363b5 100644 --- chrome/browser/supervised_user/supervised_user_settings_service_factory.h +++ chrome/browser/supervised_user/supervised_user_settings_service_factory.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_FACTORY_H_ #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_FACTORY_H_ -#include "base/memory/singleton.h" +#include "base/lazy_instance.h" #include "chrome/browser/supervised_user/supervised_users.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" @@ -20,7 +20,7 @@ class SupervisedUserSettingsServiceFactory static SupervisedUserSettingsServiceFactory* GetInstance(); private: - friend struct base::DefaultSingletonTraits< + friend struct base::LazyInstanceTraitsBase< SupervisedUserSettingsServiceFactory>; SupervisedUserSettingsServiceFactory(); diff --git chrome/browser/ui/prefs/pref_watcher.cc chrome/browser/ui/prefs/pref_watcher.cc index e38f8c50b10f..3b486f3b8daf 100644 --- chrome/browser/ui/prefs/pref_watcher.cc +++ chrome/browser/ui/prefs/pref_watcher.cc @@ -46,6 +46,9 @@ const char* const kWebPrefsToObserve[] = { const int kWebPrefsToObserveLength = base::size(kWebPrefsToObserve); +base::LazyInstance::Leaky g_pref_watcher_factory = + LAZY_INSTANCE_INITIALIZER; + } // namespace // Watching all these settings per tab is slow when a user has a lot of tabs and @@ -124,7 +127,7 @@ PrefWatcher* PrefWatcherFactory::GetForProfile(Profile* profile) { // static PrefWatcherFactory* PrefWatcherFactory::GetInstance() { - return base::Singleton::get(); + return g_pref_watcher_factory.Pointer(); } PrefWatcherFactory::PrefWatcherFactory() diff --git chrome/browser/ui/prefs/pref_watcher.h chrome/browser/ui/prefs/pref_watcher.h index 061ca27681fa..0538f62f3f25 100644 --- chrome/browser/ui/prefs/pref_watcher.h +++ chrome/browser/ui/prefs/pref_watcher.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_UI_PREFS_PREF_WATCHER_H_ #define CHROME_BROWSER_UI_PREFS_PREF_WATCHER_H_ -#include "base/memory/singleton.h" +#include "base/lazy_instance.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/core/keyed_service.h" #include "components/prefs/pref_change_registrar.h" @@ -58,7 +58,7 @@ class PrefWatcherFactory : public BrowserContextKeyedServiceFactory { static PrefWatcherFactory* GetInstance(); private: - friend struct base::DefaultSingletonTraits; + friend struct base::LazyInstanceTraitsBase; PrefWatcherFactory(); ~PrefWatcherFactory() override;