diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 16:52:35 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 16:52:35 +0000 |
commit | dc8caba097e35e536697f3bf6605257317640d26 (patch) | |
tree | c42c13e876f1eaaca5229b67325f1efd3d398155 | |
parent | 6714f3048ea032bbe62b2566583a2790d78fc644 (diff) | |
download | chromium_src-dc8caba097e35e536697f3bf6605257317640d26.zip chromium_src-dc8caba097e35e536697f3bf6605257317640d26.tar.gz chromium_src-dc8caba097e35e536697f3bf6605257317640d26.tar.bz2 |
Rename all methods accessing Singleton<T> as GetInstance().
This is in preparation to a subsequent CL where Singleton<T> will restrict access to only the type being made singleton.
This primarily covers files in chrome os and other directories, missed in the previous CL.
In a couple of files i changed Singleton<T> usage to LazyInstance<T>, because changing the method name to GetInstance() in there would require a whole lot of updates throughout the chrome os codebase.
BUG=65298
TEST=all existing tests should pass.
Review URL: http://codereview.chromium.org/5734002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69007 0039d316-1c4b-4281-b951-d872f2087c98
44 files changed, 122 insertions, 102 deletions
diff --git a/app/active_window_watcher_x.h b/app/active_window_watcher_x.h index e54ee3c..4a89686 100644 --- a/app/active_window_watcher_x.h +++ b/app/active_window_watcher_x.h @@ -26,6 +26,8 @@ class ActiveWindowWatcherX { virtual ~Observer() {} }; + static ActiveWindowWatcherX* GetInstance(); + static void AddObserver(Observer* observer); static void RemoveObserver(Observer* observer); @@ -35,8 +37,6 @@ class ActiveWindowWatcherX { ActiveWindowWatcherX(); ~ActiveWindowWatcherX(); - static ActiveWindowWatcherX* GetInstance(); - void Init(); // Sends a notification out through the NotificationService that the active diff --git a/base/linux_util.cc b/base/linux_util.cc index 62931ce..e1f7275 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc @@ -38,7 +38,7 @@ enum LinuxDistroState { class LinuxDistroHelper { public: // Retrieves the Singleton. - static LinuxDistroHelper* Get() { + static LinuxDistroHelper* GetInstance() { return Singleton<LinuxDistroHelper>::get(); } @@ -141,7 +141,7 @@ std::string GetLinuxDistro() { #if defined(OS_CHROMEOS) return g_linux_distro; #elif defined(OS_LINUX) - LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get(); + LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::GetInstance(); LinuxDistroState state = distro_state_singleton->State(); if (STATE_DID_NOT_CHECK == state) { // We do this check only once per process. If it fails, there's diff --git a/chrome/browser/child_process_launcher.cc b/chrome/browser/child_process_launcher.cc index 2586826..a4a610a 100644 --- a/chrome/browser/child_process_launcher.cc +++ b/chrome/browser/child_process_launcher.cc @@ -173,7 +173,7 @@ class ChildProcessLauncher::Context // notification will be processed by the MachBroker after the call to // AddPlaceholderForPid(), enabling proper cleanup. { // begin scope for AutoLock - MachBroker* broker = MachBroker::instance(); + MachBroker* broker = MachBroker::GetInstance(); AutoLock lock(broker->GetLock()); // This call to |PrepareForFork()| will start the MachBroker listener diff --git a/chrome/browser/chromeos/audio_handler.cc b/chrome/browser/chromeos/audio_handler.cc index 2f6638f..f8ad726 100644 --- a/chrome/browser/chromeos/audio_handler.cc +++ b/chrome/browser/chromeos/audio_handler.cc @@ -170,7 +170,7 @@ double AudioHandler::PercentToVolumeDb(double volume_percent) { } // static -AudioHandler* AudioHandler::instance() { +AudioHandler* AudioHandler::GetInstance() { return Singleton<AudioHandler>::get(); } diff --git a/chrome/browser/chromeos/audio_handler.h b/chrome/browser/chromeos/audio_handler.h index ca1a83b..59e9d70 100644 --- a/chrome/browser/chromeos/audio_handler.h +++ b/chrome/browser/chromeos/audio_handler.h @@ -17,7 +17,7 @@ class PulseAudioMixer; class AudioHandler { public: - static AudioHandler* instance(); + static AudioHandler* GetInstance(); // Get volume level in our internal 0-100% range, 0 being pure silence. // Volume may go above 100% if another process changes PulseAudio's volume. diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc index 4f7b45f..b405057 100644 --- a/chrome/browser/chromeos/boot_times_loader.cc +++ b/chrome/browser/chromeos/boot_times_loader.cc @@ -9,10 +9,10 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/lazy_instance.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "base/process_util.h" -#include "base/singleton.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -62,6 +62,9 @@ static const FilePath::CharType kLoginTimes[] = FPL("login-times-sent"); // Name of file collecting logout times. static const char kLogoutTimes[] = "logout-times-sent"; +static base::LazyInstance<BootTimesLoader> g_boot_times_loader( + base::LINKER_INITIALIZED); + BootTimesLoader::BootTimesLoader() : backend_(new Backend()), have_registered_(false) { @@ -71,7 +74,7 @@ BootTimesLoader::BootTimesLoader() // static BootTimesLoader* BootTimesLoader::Get() { - return Singleton<BootTimesLoader>::get(); + return g_boot_times_loader.Pointer(); } BootTimesLoader::Handle BootTimesLoader::GetBootTimes( @@ -373,7 +376,7 @@ void BootTimesLoader::Observe( // Only log for first tab to render. Make sure this is only done once. // If the network isn't connected we'll get a second LOAD_START once it is // and the page is reloaded. - if (NetworkStateNotifier::Get()->is_connected()) { + if (NetworkStateNotifier::GetInstance()->is_connected()) { // Post difference between first tab and login success time. AddLoginTimeMarker("LoginDone", true); RecordCurrentStats(kChromeFirstRender); diff --git a/chrome/browser/chromeos/brightness_bubble.cc b/chrome/browser/chromeos/brightness_bubble.cc index 34f4bbd..5299e4b 100644 --- a/chrome/browser/chromeos/brightness_bubble.cc +++ b/chrome/browser/chromeos/brightness_bubble.cc @@ -21,7 +21,7 @@ BrightnessBubble::BrightnessBubble() } // static -BrightnessBubble* BrightnessBubble::instance() { +BrightnessBubble* BrightnessBubble::GetInstance() { return Singleton<BrightnessBubble>::get(); } diff --git a/chrome/browser/chromeos/brightness_bubble.h b/chrome/browser/chromeos/brightness_bubble.h index 89553fc..7b5ed8c 100644 --- a/chrome/browser/chromeos/brightness_bubble.h +++ b/chrome/browser/chromeos/brightness_bubble.h @@ -16,7 +16,7 @@ namespace chromeos { // Singleton class controlling brightness bubble. class BrightnessBubble : public SettingLevelBubble { public: - static BrightnessBubble* instance(); + static BrightnessBubble* GetInstance(); private: friend struct DefaultSingletonTraits<BrightnessBubble>; diff --git a/chrome/browser/chromeos/brightness_observer.cc b/chrome/browser/chromeos/brightness_observer.cc index f501b2a..5a878dd 100644 --- a/chrome/browser/chromeos/brightness_observer.cc +++ b/chrome/browser/chromeos/brightness_observer.cc @@ -10,8 +10,8 @@ namespace chromeos { void BrightnessObserver::BrightnessChanged(int level) { - BrightnessBubble::instance()->ShowBubble(level); - VolumeBubble::instance()->HideBubble(); + BrightnessBubble::GetInstance()->ShowBubble(level); + VolumeBubble::GetInstance()->HideBubble(); } } // namespace chromeos diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc index 0c86226..d5cbe6b 100644 --- a/chrome/browser/chromeos/cros_settings.cc +++ b/chrome/browser/chromeos/cros_settings.cc @@ -4,7 +4,7 @@ #include "chrome/browser/chromeos/cros_settings.h" -#include "base/singleton.h" +#include "base/lazy_instance.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/chromeos/cros_settings_provider.h" @@ -13,9 +13,12 @@ namespace chromeos { +static base::LazyInstance<CrosSettings> g_cros_settings( + base::LINKER_INITIALIZED); + CrosSettings* CrosSettings::Get() { // TODO(xiyaun): Use real stuff when underlying libcros is ready. - return Singleton<CrosSettings>::get(); + return g_cros_settings.Pointer(); } bool CrosSettings::IsCrosSettings(const std::string& path) { diff --git a/chrome/browser/chromeos/cros_settings.h b/chrome/browser/chromeos/cros_settings.h index 226ec08..79428d2 100644 --- a/chrome/browser/chromeos/cros_settings.h +++ b/chrome/browser/chromeos/cros_settings.h @@ -16,6 +16,10 @@ #include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/common/notification_observer.h" +namespace base { +template <typename T> struct DefaultLazyInstanceTraits; +} + class Value; namespace chromeos { @@ -80,7 +84,7 @@ class CrosSettings : public NonThreadSafe { CrosSettings(); ~CrosSettings(); CrosSettingsProvider* GetProvider(const std::string& path) const; - friend struct DefaultSingletonTraits<CrosSettings>; + friend struct base::DefaultLazyInstanceTraits<CrosSettings>; DISALLOW_COPY_AND_ASSIGN(CrosSettings); }; diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc index f656a8d..f4683f5 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.cc +++ b/chrome/browser/chromeos/gview_request_interceptor.cc @@ -80,8 +80,7 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( return NULL; } -net::URLRequest::Interceptor* -GViewRequestInterceptor::GetInstance() { +GViewRequestInterceptor* GViewRequestInterceptor::GetInstance() { return Singleton<GViewRequestInterceptor>::get(); } diff --git a/chrome/browser/chromeos/gview_request_interceptor.h b/chrome/browser/chromeos/gview_request_interceptor.h index 0a1691b..9fe0139 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.h +++ b/chrome/browser/chromeos/gview_request_interceptor.h @@ -32,7 +32,7 @@ class GViewRequestInterceptor : public net::URLRequest::Interceptor { virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request); // Singleton accessor. - static net::URLRequest::Interceptor* GetInstance(); + static GViewRequestInterceptor* GetInstance(); private: friend struct DefaultSingletonTraits<GViewRequestInterceptor>; diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index 9718534..2e43129 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -192,7 +192,7 @@ void ExistingUserController::Init() { EnableTooltipsIfNeeded(controllers_); - WmMessageListener::instance()->AddObserver(this); + WmMessageListener::GetInstance()->AddObserver(this); LoginUtils::Get()->PrewarmAuthentication(); if (CrosLibrary::Get()->EnsureLoaded()) @@ -240,7 +240,7 @@ ExistingUserController::~ExistingUserController() { if (background_window_) background_window_->Close(); - WmMessageListener::instance()->RemoveObserver(this); + WmMessageListener::GetInstance()->RemoveObserver(this); STLDeleteElements(&controllers_); } diff --git a/chrome/browser/chromeos/login/ownership_service.cc b/chrome/browser/chromeos/login/ownership_service.cc index 945ab77..c256e96 100644 --- a/chrome/browser/chromeos/login/ownership_service.cc +++ b/chrome/browser/chromeos/login/ownership_service.cc @@ -6,13 +6,17 @@ #include "base/file_path.h" #include "base/file_util.h" +#include "base/lazy_instance.h" #include "chrome/browser/browser_thread.h" namespace chromeos { +static base::LazyInstance<OwnershipService> g_ownership_service( + base::LINKER_INITIALIZED); + // static OwnershipService* OwnershipService::GetSharedInstance() { - return Singleton<OwnershipService>::get(); + return g_ownership_service.Pointer(); } OwnershipService::OwnershipService() diff --git a/chrome/browser/chromeos/login/ownership_service.h b/chrome/browser/chromeos/login/ownership_service.h index 4f8227d..bc407d9 100644 --- a/chrome/browser/chromeos/login/ownership_service.h +++ b/chrome/browser/chromeos/login/ownership_service.h @@ -9,10 +9,13 @@ #include <string> #include <vector> -#include "base/singleton.h" #include "chrome/browser/chromeos/login/owner_key_utils.h" #include "chrome/browser/chromeos/login/owner_manager.h" +namespace base { +template <typename T> struct DefaultLazyInstanceTraits; +} + namespace chromeos { class OwnershipService { @@ -69,7 +72,7 @@ class OwnershipService { OwnershipService(); private: - friend struct DefaultSingletonTraits<OwnershipService>; + friend struct base::DefaultLazyInstanceTraits<OwnershipService>; friend class OwnershipServiceTest; scoped_refptr<OwnerManager> manager_; diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index f59307b..a2beddc 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -709,7 +709,7 @@ void ScreenLocker::Init() { // Create the SystemKeyEventListener so it can listen for system keyboard // messages regardless of focus while screen locked. - SystemKeyEventListener::instance(); + SystemKeyEventListener::GetInstance(); } void ScreenLocker::OnLoginFailure(const LoginFailure& error) { diff --git a/chrome/browser/chromeos/network_state_notifier.cc b/chrome/browser/chromeos/network_state_notifier.cc index 80acfaf2..b940845 100644 --- a/chrome/browser/chromeos/network_state_notifier.cc +++ b/chrome/browser/chromeos/network_state_notifier.cc @@ -17,7 +17,7 @@ using base::Time; using base::TimeDelta; // static -NetworkStateNotifier* NetworkStateNotifier::Get() { +NetworkStateNotifier* NetworkStateNotifier::GetInstance() { return Singleton<NetworkStateNotifier>::get(); } @@ -27,7 +27,7 @@ TimeDelta NetworkStateNotifier::GetOfflineDuration() { // TODO(oshima): make this instance method so that // we can mock this for ui_tests. // http://crbug.com/4825 . - return base::Time::Now() - Get()->offline_start_time_; + return base::Time::Now() - GetInstance()->offline_start_time_; } NetworkStateNotifier::NetworkStateNotifier() diff --git a/chrome/browser/chromeos/network_state_notifier.h b/chrome/browser/chromeos/network_state_notifier.h index 94e57f4..31103f0 100644 --- a/chrome/browser/chromeos/network_state_notifier.h +++ b/chrome/browser/chromeos/network_state_notifier.h @@ -48,7 +48,7 @@ class NetworkStateDetails { class NetworkStateNotifier : public NetworkLibrary::NetworkManagerObserver { public: // Returns the singleton instance of the network state notifier; - static NetworkStateNotifier* Get(); + static NetworkStateNotifier* GetInstance(); // The duration of being in offline. The value is undefined when // when network is connected. @@ -56,7 +56,7 @@ class NetworkStateNotifier : public NetworkLibrary::NetworkManagerObserver { // Returns true if the network is connected. static bool is_connected() { - return Get()->state_ == NetworkStateDetails::CONNECTED; + return GetInstance()->state_ == NetworkStateDetails::CONNECTED; } // NetworkLibrary::NetworkManagerObserver implementation. diff --git a/chrome/browser/chromeos/network_state_notifier_browsertest.cc b/chrome/browser/chromeos/network_state_notifier_browsertest.cc index 47ea0de..35490a4 100644 --- a/chrome/browser/chromeos/network_state_notifier_browsertest.cc +++ b/chrome/browser/chromeos/network_state_notifier_browsertest.cc @@ -36,7 +36,7 @@ class NetworkStateNotifierTest : public CrosInProcessBrowserTest, .Times(1) .WillRepeatedly((Return(true))) .RetiresOnSaturation(); - NetworkStateNotifier::Get(); + NetworkStateNotifier::GetInstance(); } // NotificationObserver overrides. @@ -69,7 +69,7 @@ IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { .Times(1) .WillRepeatedly((Return(true))) .RetiresOnSaturation(); - NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); + NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); notifier->OnNetworkManagerChanged(mock_network_library_); WaitForNotification(); EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); @@ -87,7 +87,7 @@ IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { .Times(1) .WillOnce((Return(true))) .RetiresOnSaturation(); - NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); + NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); notifier->OnNetworkManagerChanged(mock_network_library_); WaitForNotification(); EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); @@ -105,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { .Times(1) .WillOnce((Return(false))) .RetiresOnSaturation(); - NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); + NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); notifier->OnNetworkManagerChanged(mock_network_library_); WaitForNotification(); EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); diff --git a/chrome/browser/chromeos/system_key_event_listener.cc b/chrome/browser/chromeos/system_key_event_listener.cc index 748152c..9ebaeeb 100644 --- a/chrome/browser/chromeos/system_key_event_listener.cc +++ b/chrome/browser/chromeos/system_key_event_listener.cc @@ -21,13 +21,13 @@ const double kStepPercentage = 4.0; } // namespace // static -SystemKeyEventListener* SystemKeyEventListener::instance() { +SystemKeyEventListener* SystemKeyEventListener::GetInstance() { return Singleton<SystemKeyEventListener>::get(); } SystemKeyEventListener::SystemKeyEventListener() - : audio_handler_(AudioHandler::instance()) { - WmMessageListener::instance()->AddObserver(this); + : audio_handler_(AudioHandler::GetInstance()) { + WmMessageListener::GetInstance()->AddObserver(this); key_volume_mute_ = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioMute); key_volume_down_ = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioLowerVolume); @@ -49,7 +49,7 @@ SystemKeyEventListener::SystemKeyEventListener() } SystemKeyEventListener::~SystemKeyEventListener() { - WmMessageListener::instance()->RemoveObserver(this); + WmMessageListener::GetInstance()->RemoveObserver(this); gdk_window_remove_filter(NULL, GdkEventFilter, this); } @@ -131,19 +131,19 @@ void SystemKeyEventListener::OnVolumeMute() { // Always muting (and not toggling) as per final decision on // http://crosbug.com/3751 audio_handler_->SetMute(true); - VolumeBubble::instance()->ShowBubble(0); - BrightnessBubble::instance()->HideBubble(); + VolumeBubble::GetInstance()->ShowBubble(0); + BrightnessBubble::GetInstance()->HideBubble(); } void SystemKeyEventListener::OnVolumeDown() { if (audio_handler_->IsMute()) { - VolumeBubble::instance()->ShowBubble(0); + VolumeBubble::GetInstance()->ShowBubble(0); } else { audio_handler_->AdjustVolumeByPercent(-kStepPercentage); - VolumeBubble::instance()->ShowBubble( + VolumeBubble::GetInstance()->ShowBubble( audio_handler_->GetVolumePercent()); } - BrightnessBubble::instance()->HideBubble(); + BrightnessBubble::GetInstance()->HideBubble(); } void SystemKeyEventListener::OnVolumeUp() { @@ -151,9 +151,9 @@ void SystemKeyEventListener::OnVolumeUp() { audio_handler_->SetMute(false); else audio_handler_->AdjustVolumeByPercent(kStepPercentage); - VolumeBubble::instance()->ShowBubble( + VolumeBubble::GetInstance()->ShowBubble( audio_handler_->GetVolumePercent()); - BrightnessBubble::instance()->HideBubble(); + BrightnessBubble::GetInstance()->HideBubble(); } } // namespace chromeos diff --git a/chrome/browser/chromeos/system_key_event_listener.h b/chrome/browser/chromeos/system_key_event_listener.h index 61a20ca..eb841f9 100644 --- a/chrome/browser/chromeos/system_key_event_listener.h +++ b/chrome/browser/chromeos/system_key_event_listener.h @@ -24,7 +24,7 @@ class AudioHandler; class SystemKeyEventListener : public WmMessageListener::Observer { public: - static SystemKeyEventListener* instance(); + static SystemKeyEventListener* GetInstance(); // WmMessageListener::Observer: virtual void ProcessWmMessage(const WmIpc::Message& message, diff --git a/chrome/browser/chromeos/usb_mount_observer.cc b/chrome/browser/chromeos/usb_mount_observer.cc index e63718f..6f056e8 100644 --- a/chrome/browser/chromeos/usb_mount_observer.cc +++ b/chrome/browser/chromeos/usb_mount_observer.cc @@ -25,7 +25,7 @@ const int kPopupWidth = 250; const int kPopupHeight = 300; // static -USBMountObserver* USBMountObserver::Get() { +USBMountObserver* USBMountObserver::GetInstance() { return Singleton<USBMountObserver>::get(); } diff --git a/chrome/browser/chromeos/usb_mount_observer.h b/chrome/browser/chromeos/usb_mount_observer.h index 66ab2bf..0857197 100644 --- a/chrome/browser/chromeos/usb_mount_observer.h +++ b/chrome/browser/chromeos/usb_mount_observer.h @@ -32,7 +32,7 @@ class USBMountObserver : public chromeos::MountLibrary::Observer, std::string mount_path; }; - static USBMountObserver* Get(); + static USBMountObserver* GetInstance(); void Observe(NotificationType type, const NotificationSource& source, diff --git a/chrome/browser/chromeos/usb_mount_observer_browsertest.cc b/chrome/browser/chromeos/usb_mount_observer_browsertest.cc index 6c8d12e..c70fbeb 100644 --- a/chrome/browser/chromeos/usb_mount_observer_browsertest.cc +++ b/chrome/browser/chromeos/usb_mount_observer_browsertest.cc @@ -42,7 +42,7 @@ IN_PROC_BROWSER_TEST_F(USBMountObserverBrowserTest, PopupOnEvent) { // Doing this so we have a valid profile ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); - chromeos::USBMountObserver* observe = chromeos::USBMountObserver::Get(); + chromeos::USBMountObserver* observe = chromeos::USBMountObserver::GetInstance(); observe->set_profile(browser()->profile()); scoped_ptr<chromeos::MockMountLibrary> lib(new chromeos::MockMountLibrary()); lib->AddObserver(observe); diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc index e469f7f..4ee00f1 100644 --- a/chrome/browser/chromeos/user_cros_settings_provider.cc +++ b/chrome/browser/chromeos/user_cros_settings_provider.cc @@ -157,7 +157,7 @@ bool GetUserWhitelist(ListValue* user_list) { class UserCrosSettingsTrust : public SignedSettingsHelper::Callback, public NotificationObserver { public: - static UserCrosSettingsTrust* GetSharedInstance() { + static UserCrosSettingsTrust* GetInstance() { return Singleton<UserCrosSettingsTrust>::get(); } @@ -432,7 +432,7 @@ namespace chromeos { UserCrosSettingsProvider::UserCrosSettingsProvider() { // Trigger prefetching of settings. - UserCrosSettingsTrust::GetSharedInstance(); + UserCrosSettingsTrust::GetInstance(); } // static @@ -446,36 +446,36 @@ void UserCrosSettingsProvider::RegisterPrefs(PrefService* local_state) { } bool UserCrosSettingsProvider::RequestTrustedAllowGuest(Task* callback) { - return UserCrosSettingsTrust::GetSharedInstance()->RequestTrustedEntity( + return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( kAccountsPrefAllowGuest, callback); } bool UserCrosSettingsProvider::RequestTrustedAllowNewUser(Task* callback) { - return UserCrosSettingsTrust::GetSharedInstance()->RequestTrustedEntity( + return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( kAccountsPrefAllowNewUser, callback); } bool UserCrosSettingsProvider::RequestTrustedShowUsersOnSignin(Task* callback) { - return UserCrosSettingsTrust::GetSharedInstance()->RequestTrustedEntity( + return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( kAccountsPrefShowUserNamesOnSignIn, callback); } bool UserCrosSettingsProvider::RequestTrustedOwner(Task* callback) { - return UserCrosSettingsTrust::GetSharedInstance()->RequestTrustedEntity( + return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( kDeviceOwner, callback); } // static bool UserCrosSettingsProvider::cached_allow_guest() { // Trigger prefetching if singleton object still does not exist. - UserCrosSettingsTrust::GetSharedInstance(); + UserCrosSettingsTrust::GetInstance(); return g_browser_process->local_state()->GetBoolean(kAccountsPrefAllowGuest); } // static bool UserCrosSettingsProvider::cached_allow_new_user() { // Trigger prefetching if singleton object still does not exist. - UserCrosSettingsTrust::GetSharedInstance(); + UserCrosSettingsTrust::GetInstance(); return g_browser_process->local_state()->GetBoolean( kAccountsPrefAllowNewUser); } @@ -483,7 +483,7 @@ bool UserCrosSettingsProvider::cached_allow_new_user() { // static bool UserCrosSettingsProvider::cached_show_users_on_signin() { // Trigger prefetching if singleton object still does not exist. - UserCrosSettingsTrust::GetSharedInstance(); + UserCrosSettingsTrust::GetInstance(); return g_browser_process->local_state()->GetBoolean( kAccountsPrefShowUserNamesOnSignIn); } @@ -506,7 +506,7 @@ const ListValue* UserCrosSettingsProvider::cached_whitelist() { // static std::string UserCrosSettingsProvider::cached_owner() { // Trigger prefetching if singleton object still does not exist. - UserCrosSettingsTrust::GetSharedInstance(); + UserCrosSettingsTrust::GetInstance(); if (!g_browser_process || !g_browser_process->local_state()) return std::string(); return g_browser_process->local_state()->GetString(kDeviceOwner); @@ -529,7 +529,7 @@ bool UserCrosSettingsProvider::IsEmailInCachedWhitelist( void UserCrosSettingsProvider::DoSet(const std::string& path, Value* in_value) { - UserCrosSettingsTrust::GetSharedInstance()->Set(path, in_value); + UserCrosSettingsTrust::GetInstance()->Set(path, in_value); } bool UserCrosSettingsProvider::Get(const std::string& path, @@ -555,7 +555,7 @@ bool UserCrosSettingsProvider::HandlesSetting(const std::string& path) { void UserCrosSettingsProvider::WhitelistUser(const std::string& email) { SignedSettingsHelper::Get()->StartWhitelistOp( - email, true, UserCrosSettingsTrust::GetSharedInstance()); + email, true, UserCrosSettingsTrust::GetInstance()); PrefService* prefs = g_browser_process->local_state(); ListValue* cached_whitelist = prefs->GetMutableList(kAccountsPrefUsers); cached_whitelist->Append(Value::CreateStringValue(email)); @@ -564,7 +564,7 @@ void UserCrosSettingsProvider::WhitelistUser(const std::string& email) { void UserCrosSettingsProvider::UnwhitelistUser(const std::string& email) { SignedSettingsHelper::Get()->StartWhitelistOp( - email, false, UserCrosSettingsTrust::GetSharedInstance()); + email, false, UserCrosSettingsTrust::GetInstance()); PrefService* prefs = g_browser_process->local_state(); ListValue* cached_whitelist = prefs->GetMutableList(kAccountsPrefUsers); diff --git a/chrome/browser/chromeos/volume_bubble.cc b/chrome/browser/chromeos/volume_bubble.cc index 0846885..ec9d365 100644 --- a/chrome/browser/chromeos/volume_bubble.cc +++ b/chrome/browser/chromeos/volume_bubble.cc @@ -21,7 +21,7 @@ VolumeBubble::VolumeBubble() } // static -VolumeBubble* VolumeBubble::instance() { +VolumeBubble* VolumeBubble::GetInstance() { return Singleton<VolumeBubble>::get(); } diff --git a/chrome/browser/chromeos/volume_bubble.h b/chrome/browser/chromeos/volume_bubble.h index efbdc5f..17f72fc 100644 --- a/chrome/browser/chromeos/volume_bubble.h +++ b/chrome/browser/chromeos/volume_bubble.h @@ -16,7 +16,7 @@ namespace chromeos { // Singleton class controlling volume bubble. class VolumeBubble : public SettingLevelBubble { public: - static VolumeBubble* instance(); + static VolumeBubble* GetInstance(); private: friend struct DefaultSingletonTraits<VolumeBubble>; diff --git a/chrome/browser/chromeos/wm_ipc.cc b/chrome/browser/chromeos/wm_ipc.cc index 1dd0af5..aa09dd7 100644 --- a/chrome/browser/chromeos/wm_ipc.cc +++ b/chrome/browser/chromeos/wm_ipc.cc @@ -10,9 +10,9 @@ extern "C" { } #include "app/x11_util.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/scoped_ptr.h" -#include "base/singleton.h" namespace chromeos { @@ -59,12 +59,11 @@ bool SetIntProperty(XID xid, Atom xatom, const std::vector<int>& values) { } // namespace +static base::LazyInstance<WmIpc> g_wm_ipc(base::LINKER_INITIALIZED); + // static WmIpc* WmIpc::instance() { - static WmIpc* instance = NULL; - if (!instance) - instance = Singleton<WmIpc>::get(); - return instance; + return g_wm_ipc.Pointer(); } bool WmIpc::SetWindowType(GtkWidget* widget, diff --git a/chrome/browser/chromeos/wm_ipc.h b/chrome/browser/chromeos/wm_ipc.h index 92fef71..4437598 100644 --- a/chrome/browser/chromeos/wm_ipc.h +++ b/chrome/browser/chromeos/wm_ipc.h @@ -12,12 +12,15 @@ #include <vector> #include "base/logging.h" -#include "base/singleton.h" #include "cros/chromeos_wm_ipc_enums.h" typedef unsigned long Atom; typedef unsigned long XID; +namespace base { +template <typename T> struct DefaultLazyInstanceTraits; +} + namespace chromeos { class WmIpc { @@ -113,7 +116,7 @@ class WmIpc { void SetLoggedInProperty(bool logged_in); private: - friend struct DefaultSingletonTraits<WmIpc>; + friend struct base::DefaultLazyInstanceTraits<WmIpc>; WmIpc(); diff --git a/chrome/browser/chromeos/wm_message_listener.cc b/chrome/browser/chromeos/wm_message_listener.cc index adbba2e..c0815e4 100644 --- a/chrome/browser/chromeos/wm_message_listener.cc +++ b/chrome/browser/chromeos/wm_message_listener.cc @@ -7,7 +7,7 @@ namespace chromeos { // static -WmMessageListener* WmMessageListener::instance() { +WmMessageListener* WmMessageListener::GetInstance() { static WmMessageListener* instance = NULL; if (!instance) { instance = Singleton<WmMessageListener>::get(); diff --git a/chrome/browser/chromeos/wm_message_listener.h b/chrome/browser/chromeos/wm_message_listener.h index f389c4c..36ba475 100644 --- a/chrome/browser/chromeos/wm_message_listener.h +++ b/chrome/browser/chromeos/wm_message_listener.h @@ -31,7 +31,7 @@ class WmMessageListener : public MessageLoopForUI::Observer { GdkWindow* window) = 0; }; - static WmMessageListener* instance(); + static WmMessageListener* GetInstance(); void AddObserver(Observer* observer) { observers_.AddObserver(observer); diff --git a/chrome/browser/chromeos/wm_overview_controller.cc b/chrome/browser/chromeos/wm_overview_controller.cc index b041bd7..1de3330 100644 --- a/chrome/browser/chromeos/wm_overview_controller.cc +++ b/chrome/browser/chromeos/wm_overview_controller.cc @@ -453,7 +453,7 @@ void BrowserListener::RenumberSnapshots(int start_index) { // WmOverviewController methods // static -WmOverviewController* WmOverviewController::instance() { +WmOverviewController* WmOverviewController::GetInstance() { static WmOverviewController* instance = NULL; if (!instance) { instance = Singleton<WmOverviewController>::get(); @@ -483,11 +483,11 @@ WmOverviewController::WmOverviewController() } BrowserList::AddObserver(this); - WmMessageListener::instance()->AddObserver(this); + WmMessageListener::GetInstance()->AddObserver(this); } WmOverviewController::~WmOverviewController() { - WmMessageListener::instance()->RemoveObserver(this); + WmMessageListener::GetInstance()->RemoveObserver(this); BrowserList::RemoveObserver(this); listeners_.clear(); } diff --git a/chrome/browser/chromeos/wm_overview_controller.h b/chrome/browser/chromeos/wm_overview_controller.h index 8618e3e..d5999b5 100644 --- a/chrome/browser/chromeos/wm_overview_controller.h +++ b/chrome/browser/chromeos/wm_overview_controller.h @@ -64,7 +64,7 @@ class WmOverviewController : public BrowserList::Observer, }; // This class is a singleton. - static WmOverviewController* instance(); + static WmOverviewController* GetInstance(); // BrowserList::Observer methods void OnBrowserAdded(const Browser* browser) {} diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 04733f7..41ab3c2 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -622,7 +622,7 @@ void FilebrowseHandler::PlayMediaFile(const ListValue* args) { Browser* browser = Browser::GetBrowserForController( &tab_contents_->controller(), NULL); - MediaPlayer* mediaplayer = MediaPlayer::Get(); + MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); mediaplayer->ForcePlayMediaURL(gurl, browser); #endif } @@ -634,7 +634,7 @@ void FilebrowseHandler::EnqueueMediaFile(const ListValue* args) { Browser* browser = Browser::GetBrowserForController( &tab_contents_->controller(), NULL); - MediaPlayer* mediaplayer = MediaPlayer::Get(); + MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); mediaplayer->EnqueueMediaURL(gurl, browser); #endif } diff --git a/chrome/browser/dom_ui/mediaplayer_browsertest.cc b/chrome/browser/dom_ui/mediaplayer_browsertest.cc index 17cfe27..74cbc30 100644 --- a/chrome/browser/dom_ui/mediaplayer_browsertest.cc +++ b/chrome/browser/dom_ui/mediaplayer_browsertest.cc @@ -69,7 +69,7 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { ui_test_utils::NavigateToURL(browser(), GURL("chrome://downloads")); - MediaPlayer* player = MediaPlayer::Get(); + MediaPlayer* player = MediaPlayer::GetInstance(); // Check that its not currently visible ASSERT_FALSE(IsPlayerVisible()); @@ -85,7 +85,7 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) { GURL("chrome://downloads")); - MediaPlayer* player = MediaPlayer::Get(); + MediaPlayer* player = MediaPlayer::GetInstance(); player->EnqueueMediaURL(GetMusicTestURL(), NULL); diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index f69ebcd..85c53f6 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -220,7 +220,7 @@ DOMMessageHandler* MediaplayerHandler::Attach(DOMUI* dom_ui) { } void MediaplayerHandler::Init(bool is_playlist, TabContents* contents) { - MediaPlayer* player = MediaPlayer::Get(); + MediaPlayer* player = MediaPlayer::GetInstance(); if (!is_playlist) { player->SetNewHandler(this, contents); } else { @@ -258,7 +258,7 @@ void MediaplayerHandler::PlaybackMediaFile(const GURL& url) { current_playlist_.clear(); current_playlist_.push_back(MediaplayerHandler::MediaUrl(url)); FirePlaylistChanged(url.spec(), true, 0); - MediaPlayer::Get()->NotifyPlaylistChanged(); + MediaPlayer::GetInstance()->NotifyPlaylistChanged(); } const MediaplayerHandler::UrlVector& MediaplayerHandler::GetCurrentPlaylist() { @@ -270,13 +270,13 @@ int MediaplayerHandler::GetCurrentPlaylistOffset() { } void MediaplayerHandler::HandleToggleFullscreen(const ListValue* args) { - MediaPlayer::Get()->ToggleFullscreen(); + MediaPlayer::GetInstance()->ToggleFullscreen(); } void MediaplayerHandler::HandleSetCurrentPlaylistOffset(const ListValue* args) { int id; CHECK(ExtractIntegerValue(args, &id)); - MediaPlayer::Get()->SetPlaylistOffset(id); + MediaPlayer::GetInstance()->SetPlaylistOffset(id); } void MediaplayerHandler::FirePlaylistChanged(const std::string& path, @@ -306,12 +306,12 @@ void MediaplayerHandler::SetCurrentPlaylist( void MediaplayerHandler::EnqueueMediaFile(const GURL& url) { current_playlist_.push_back(MediaplayerHandler::MediaUrl(url)); FirePlaylistChanged(url.spec(), false, current_offset_); - MediaPlayer::Get()->NotifyPlaylistChanged(); + MediaPlayer::GetInstance()->NotifyPlaylistChanged(); } void MediaplayerHandler::HandleCurrentOffsetChanged(const ListValue* args) { CHECK(ExtractIntegerValue(args, ¤t_offset_)); - MediaPlayer::Get()->NotifyPlaylistChanged(); + MediaPlayer::GetInstance()->NotifyPlaylistChanged(); } void MediaplayerHandler::HandlePlaybackError(const ListValue* args) { @@ -335,11 +335,11 @@ void MediaplayerHandler::HandleGetCurrentPlaylist(const ListValue* args) { } void MediaplayerHandler::HandleTogglePlaylist(const ListValue* args) { - MediaPlayer::Get()->TogglePlaylistWindowVisible(); + MediaPlayer::GetInstance()->TogglePlaylistWindowVisible(); } void MediaplayerHandler::HandleShowPlaylist(const ListValue* args) { - MediaPlayer::Get()->ShowPlaylistWindow(); + MediaPlayer::GetInstance()->ShowPlaylistWindow(); } //////////////////////////////////////////////////////////////////////////////// @@ -356,7 +356,7 @@ MediaPlayer::~MediaPlayer() { } // static -MediaPlayer* MediaPlayer::Get() { +MediaPlayer* MediaPlayer::GetInstance() { return Singleton<MediaPlayer>::get(); } diff --git a/chrome/browser/dom_ui/mediaplayer_ui.h b/chrome/browser/dom_ui/mediaplayer_ui.h index c7168ee..921190a 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.h +++ b/chrome/browser/dom_ui/mediaplayer_ui.h @@ -89,7 +89,7 @@ class MediaPlayer : public NotificationObserver, const NotificationDetails& details); // Getter for the singleton. - static MediaPlayer* Get(); + static MediaPlayer* GetInstance(); private: friend struct DefaultSingletonTraits<MediaPlayer>; diff --git a/chrome/browser/mach_broker_mac.cc b/chrome/browser/mach_broker_mac.cc index 18bb546..b3afe94 100644 --- a/chrome/browser/mach_broker_mac.cc +++ b/chrome/browser/mach_broker_mac.cc @@ -121,7 +121,7 @@ class MachListenerThreadDelegate : public PlatformThread::Delegate { }; // Returns the global MachBroker. -MachBroker* MachBroker::instance() { +MachBroker* MachBroker::GetInstance() { return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get(); } diff --git a/chrome/browser/mach_broker_mac.h b/chrome/browser/mach_broker_mac.h index 7b0257f..2007055 100644 --- a/chrome/browser/mach_broker_mac.h +++ b/chrome/browser/mach_broker_mac.h @@ -36,7 +36,7 @@ class MachBroker : public base::ProcessMetrics::PortProvider, public NotificationObserver { public: // Returns the global MachBroker. - static MachBroker* instance(); + static MachBroker* GetInstance(); // Performs any necessary setup that cannot happen in the constructor. // Clients MUST call this method before fork()ing any children. diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index b8fd8e3..f059385 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -88,7 +88,7 @@ void OpenItem(const FilePath& full_path) { ext == ".mp3" || ext == ".mkv" || ext == ".ogg") { - MediaPlayer* mediaplayer = MediaPlayer::Get(); + MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); std::string url = "file://"; url += full_path.value(); GURL gurl(url); diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 38531d8..2dc5029 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -627,7 +627,7 @@ void TaskManagerModel::AddResource(TaskManager::Resource* resource) { base::ProcessMetrics::CreateProcessMetrics(process); #else base::ProcessMetrics::CreateProcessMetrics(process, - MachBroker::instance()); + MachBroker::GetInstance()); #endif metrics_map_[process] = pm; diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 8c3f4ea..640cbee 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -397,7 +397,8 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line, // because the page load can happen in parallel to this UI thread // and IO thread may access the NetworkStateNotifier. chromeos::CrosLibrary::Get()->GetNetworkLibrary() - ->AddNetworkManagerObserver(chromeos::NetworkStateNotifier::Get()); + ->AddNetworkManagerObserver( + chromeos::NetworkStateNotifier::GetInstance()); } #endif @@ -419,14 +420,14 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line, #if defined(OS_CHROMEOS) // Create the WmMessageListener so that it can listen for messages regardless // of what window has focus. - chromeos::WmMessageListener::instance(); + chromeos::WmMessageListener::GetInstance(); // Create the SystemKeyEventListener so it can listen for system keyboard // messages regardless of focus. - chromeos::SystemKeyEventListener::instance(); + chromeos::SystemKeyEventListener::GetInstance(); // Create the WmOverviewController so it can register with the listener. - chromeos::WmOverviewController::instance(); + chromeos::WmOverviewController::GetInstance(); // Install the GView request interceptor that will redirect requests // of compatible documents (PDF, etc) to the GView document viewer. @@ -439,7 +440,8 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line, // and have the constructor take care of everything else. chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary(); - chromeos::USBMountObserver* observe = chromeos::USBMountObserver::Get(); + chromeos::USBMountObserver* observe = + chromeos::USBMountObserver::GetInstance(); lib->AddObserver(observe); observe->ScanForDevices(lib); // Connect the chromeos notifications diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index b56a03d..6520fea 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -131,7 +131,7 @@ class WidgetGtk::DropObserver : public MessageLoopForUI::Observer { public: DropObserver() {} - static DropObserver* Get() { + static DropObserver* GetInstance() { return Singleton<DropObserver>::get(); } @@ -253,7 +253,7 @@ WidgetGtk::WidgetGtk(Type type) installed_message_loop_observer = true; MessageLoopForUI* loop = MessageLoopForUI::current(); if (loop) - loop->AddObserver(DropObserver::Get()); + loop->AddObserver(DropObserver::GetInstance()); } if (type_ != TYPE_CHILD) |