summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 16:42:15 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 16:42:15 +0000
commitfee46a89f493080db0838e2314b4400faeec94f3 (patch)
tree6e857fcf0b6b548b526c45d24879ad6422d50856 /chrome/browser/chromeos
parentf2d1f61006eac0f8a051fa485b2cffb6b6fa74e0 (diff)
downloadchromium_src-fee46a89f493080db0838e2314b4400faeec94f3.zip
chromium_src-fee46a89f493080db0838e2314b4400faeec94f3.tar.gz
chromium_src-fee46a89f493080db0838e2314b4400faeec94f3.tar.bz2
This is a continuation of http://codereview.chromium.org/5519016/, adds a new GetInstance() method for remaining files with singleton classes under chrome/browser.
For types declared and used within the same .cc file, I changed them over to LazyInstance<T>. BUG=65298 TEST=all existing tests should continue to pass. Review URL: http://codereview.chromium.org/5711001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/audio_handler.cc6
-rw-r--r--chrome/browser/chromeos/audio_handler.h8
-rw-r--r--chrome/browser/chromeos/dom_ui/imageburner_ui.cc9
-rw-r--r--chrome/browser/chromeos/dom_ui/imageburner_ui.h11
-rw-r--r--chrome/browser/chromeos/gview_request_interceptor.h10
-rw-r--r--chrome/browser/chromeos/input_method/input_method_util.cc21
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc12
-rw-r--r--chrome/browser/chromeos/login/signed_settings_temp_storage.cc6
-rw-r--r--chrome/browser/chromeos/usb_mount_observer.cc6
-rw-r--r--chrome/browser/chromeos/usb_mount_observer.h11
-rw-r--r--chrome/browser/chromeos/volume_bubble.cc6
-rw-r--r--chrome/browser/chromeos/volume_bubble.h7
12 files changed, 81 insertions, 32 deletions
diff --git a/chrome/browser/chromeos/audio_handler.cc b/chrome/browser/chromeos/audio_handler.cc
index a463e29..2f6638f 100644
--- a/chrome/browser/chromeos/audio_handler.cc
+++ b/chrome/browser/chromeos/audio_handler.cc
@@ -7,6 +7,7 @@
#include <math.h>
#include "base/logging.h"
+#include "base/singleton.h"
#include "chrome/browser/chromeos/pulse_audio_mixer.h"
namespace chromeos {
@@ -168,4 +169,9 @@ double AudioHandler::PercentToVolumeDb(double volume_percent) {
(kMaxVolumeDb - kMinVolumeDb) + kMinVolumeDb;
}
+// static
+AudioHandler* AudioHandler::instance() {
+ return Singleton<AudioHandler>::get();
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/audio_handler.h b/chrome/browser/chromeos/audio_handler.h
index 67addcb..ca1a83b 100644
--- a/chrome/browser/chromeos/audio_handler.h
+++ b/chrome/browser/chromeos/audio_handler.h
@@ -6,8 +6,10 @@
#define CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_
#pragma once
+#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-#include "base/singleton.h"
+
+template <typename T> struct DefaultSingletonTraits;
namespace chromeos {
@@ -15,9 +17,7 @@ class PulseAudioMixer;
class AudioHandler {
public:
- static AudioHandler* instance() {
- return Singleton<AudioHandler>::get();
- }
+ static AudioHandler* instance();
// 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/dom_ui/imageburner_ui.cc b/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
index c285163..75d8b40 100644
--- a/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/imageburner_ui.cc
@@ -105,7 +105,7 @@ ImageBurnHandler::ImageBurnHandler(TabContents* contents)
chromeos::CrosLibrary::Get()->GetBurnLibrary();
burn_lib->AddObserver(this);
local_image_file_path_.clear();
- burn_resource_manager_ = Singleton<ImageBurnResourceManager>::get();
+ burn_resource_manager_ = ImageBurnResourceManager::GetInstance();
}
ImageBurnHandler::~ImageBurnHandler() {
@@ -398,7 +398,7 @@ void ImageBurnHandler::CreateLocalImagePath() {
ImageBurnTaskProxy::ImageBurnTaskProxy(
const base::WeakPtr<ImageBurnHandler>& handler)
: handler_(handler) {
- resource_manager_ = Singleton<ImageBurnResourceManager>::get();
+ resource_manager_ = ImageBurnResourceManager::GetInstance();
}
bool ImageBurnTaskProxy::ReportDownloadInitialized() {
@@ -464,6 +464,11 @@ ImageBurnResourceManager::~ImageBurnResourceManager() {
download_manager_->RemoveObserver(this);
}
+// static
+ImageBurnResourceManager* ImageBurnResourceManager::GetInstance() {
+ return Singleton<ImageBurnResourceManager>::get();
+}
+
void ImageBurnResourceManager::OnDownloadUpdated(DownloadItem* download) {
if (download->state() == DownloadItem::CANCELLED) {
image_url_.reset();
diff --git a/chrome/browser/chromeos/dom_ui/imageburner_ui.h b/chrome/browser/chromeos/dom_ui/imageburner_ui.h
index 0f2560a..5803762 100644
--- a/chrome/browser/chromeos/dom_ui/imageburner_ui.h
+++ b/chrome/browser/chromeos/dom_ui/imageburner_ui.h
@@ -26,6 +26,8 @@
#include "googleurl/src/gurl.h"
#include "net/base/file_stream.h"
+template <typename T> struct DefaultSingletonTraits;
+
static const std::string kPropertyPath = "path";
static const std::string kPropertyTitle = "title";
static const std::string kPropertyDirectory = "isDirectory";
@@ -158,8 +160,8 @@ class ImageBurnTaskProxy
class ImageBurnResourceManager : public DownloadManager::Observer,
public DownloadItem::Observer {
public:
- ImageBurnResourceManager();
- ~ImageBurnResourceManager();
+ // Returns the singleton instance.
+ static ImageBurnResourceManager* GetInstance();
// DownloadItem::Observer interface
virtual void OnDownloadUpdated(DownloadItem* download);
@@ -190,6 +192,11 @@ class ImageBurnResourceManager : public DownloadManager::Observer,
net::FileStream* CreateFileStream(FilePath* file_path);
private:
+ friend struct DefaultSingletonTraits<ImageBurnResourceManager>;
+
+ ImageBurnResourceManager();
+ ~ImageBurnResourceManager();
+
FilePath local_image_dir_file_path_;
FilePath image_fecher_local_path_;
bool image_download_started_;
diff --git a/chrome/browser/chromeos/gview_request_interceptor.h b/chrome/browser/chromeos/gview_request_interceptor.h
index 7642d1d..cd8dfde 100644
--- a/chrome/browser/chromeos/gview_request_interceptor.h
+++ b/chrome/browser/chromeos/gview_request_interceptor.h
@@ -10,6 +10,8 @@
#include "base/hash_tables.h"
#include "net/url_request/url_request.h"
+template <typename T> struct DefaultSingletonTraits;
+
namespace chromeos {
// This class integrates the Google Document Viewer into ChromeOS,
@@ -20,9 +22,6 @@ namespace chromeos {
// parameter.
class GViewRequestInterceptor : public net::URLRequest::Interceptor {
public:
- GViewRequestInterceptor();
- virtual ~GViewRequestInterceptor();
-
// Always returns NULL because we don't want to attempt a redirect
// before seeing the detected mime type of the request.
virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request);
@@ -36,6 +35,11 @@ class GViewRequestInterceptor : public net::URLRequest::Interceptor {
static net::URLRequest::Interceptor* GetGViewRequestInterceptor();
private:
+ friend struct DefaultSingletonTraits<GViewRequestInterceptor>;
+
+ GViewRequestInterceptor();
+ virtual ~GViewRequestInterceptor();
+
// The list of supported mime types.
base::hash_set<std::string> supported_mime_types_;
};
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc
index 9f8811d..fbc904b 100644
--- a/chrome/browser/chromeos/input_method/input_method_util.cc
+++ b/chrome/browser/chromeos/input_method/input_method_util.cc
@@ -109,6 +109,11 @@ struct IdMaps {
scoped_ptr<std::map<std::string, std::string> > id_to_display_name;
scoped_ptr<std::map<std::string, std::string> > id_to_keyboard_overlay_id;
+ // Returns the singleton instance.
+ static IdMaps* GetInstance() {
+ return Singleton<IdMaps>::get();
+ }
+
void ReloadMaps() {
chromeos::InputMethodLibrary* library =
chromeos::CrosLibrary::Get()->GetInputMethodLibrary();
@@ -536,8 +541,8 @@ std::string GetLanguageCodeFromInputMethodId(
// defined in app/l10_util.cc.
const char kDefaultLanguageCode[] = "en-US";
std::map<std::string, std::string>::const_iterator iter
- = Singleton<IdMaps>::get()->id_to_language_code->find(input_method_id);
- return (iter == Singleton<IdMaps>::get()->id_to_language_code->end()) ?
+ = IdMaps::GetInstance()->id_to_language_code->find(input_method_id);
+ return (iter == IdMaps::GetInstance()->id_to_language_code->end()) ?
// Returning |kDefaultLanguageCode| here is not for Chrome OS but for
// Ubuntu where the ibus-xkb-layouts engine could be missing.
kDefaultLanguageCode : iter->second;
@@ -555,7 +560,7 @@ std::string GetKeyboardLayoutName(const std::string& input_method_id) {
std::string GetKeyboardOverlayId(const std::string& input_method_id) {
const std::map<std::string, std::string>& id_map =
- *(Singleton<IdMaps>::get()->id_to_keyboard_overlay_id);
+ *(IdMaps::GetInstance()->id_to_keyboard_overlay_id);
std::map<std::string, std::string>::const_iterator iter =
id_map.find(input_method_id);
return (iter == id_map.end() ? "" : iter->second);
@@ -565,8 +570,8 @@ std::string GetInputMethodDisplayNameFromId(
const std::string& input_method_id) {
static const char kDefaultDisplayName[] = "USA";
std::map<std::string, std::string>::const_iterator iter
- = Singleton<IdMaps>::get()->id_to_display_name->find(input_method_id);
- return (iter == Singleton<IdMaps>::get()->id_to_display_name->end()) ?
+ = IdMaps::GetInstance()->id_to_display_name->find(input_method_id);
+ return (iter == IdMaps::GetInstance()->id_to_display_name->end()) ?
kDefaultDisplayName : iter->second;
}
@@ -603,7 +608,7 @@ void SortLanguageCodesByNames(std::vector<std::string>* language_codes) {
void SortInputMethodIdsByNames(std::vector<std::string>* input_method_ids) {
SortInputMethodIdsByNamesInternal(
- *(Singleton<IdMaps>::get()->id_to_language_code), input_method_ids);
+ *(IdMaps::GetInstance()->id_to_language_code), input_method_ids);
}
void SortInputMethodIdsByNamesInternal(
@@ -629,7 +634,7 @@ bool GetInputMethodIdsFromLanguageCode(
InputMethodType type,
std::vector<std::string>* out_input_method_ids) {
return GetInputMethodIdsFromLanguageCodeInternal(
- *Singleton<IdMaps>::get()->language_code_to_ids,
+ *IdMaps::GetInstance()->language_code_to_ids,
normalized_language_code, type, out_input_method_ids);
}
@@ -687,7 +692,7 @@ void EnableInputMethods(const std::string& language_code, InputMethodType type,
}
void OnLocaleChanged() {
- Singleton<IdMaps>::get()->ReloadMaps();
+ IdMaps::GetInstance()->ReloadMaps();
}
} // namespace input_method
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index ad8da19..11df756 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -143,7 +143,9 @@ class LoginUtilsImpl : public LoginUtils {
class LoginUtilsWrapper {
public:
- LoginUtilsWrapper() {}
+ static LoginUtilsWrapper* GetInstance() {
+ return Singleton<LoginUtilsWrapper>::get();
+ }
LoginUtils* get() {
AutoLock create(create_lock_);
@@ -157,6 +159,10 @@ class LoginUtilsWrapper {
}
private:
+ friend struct DefaultSingletonTraits<LoginUtilsWrapper>;
+
+ LoginUtilsWrapper() {}
+
Lock create_lock_;
scoped_ptr<LoginUtils> ptr_;
@@ -454,11 +460,11 @@ void LoginUtilsImpl::PrewarmAuthentication() {
}
LoginUtils* LoginUtils::Get() {
- return Singleton<LoginUtilsWrapper>::get()->get();
+ return LoginUtilsWrapper::GetInstance()->get();
}
void LoginUtils::Set(LoginUtils* mock) {
- Singleton<LoginUtilsWrapper>::get()->reset(mock);
+ LoginUtilsWrapper::GetInstance()->reset(mock);
}
void LoginUtils::DoBrowserLaunch(Profile* profile) {
diff --git a/chrome/browser/chromeos/login/signed_settings_temp_storage.cc b/chrome/browser/chromeos/login/signed_settings_temp_storage.cc
index 2e731a5..24a0b38 100644
--- a/chrome/browser/chromeos/login/signed_settings_temp_storage.cc
+++ b/chrome/browser/chromeos/login/signed_settings_temp_storage.cc
@@ -4,12 +4,16 @@
#include "chrome/browser/chromeos/login/signed_settings_temp_storage.h"
+#include "base/lazy_instance.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/ownership_service.h"
#include "chrome/browser/chromeos/login/signed_settings.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
+static base::LazyInstance<chromeos::SignedSettings::Delegate<bool> >
+ g_signed_settings_delegate(base::LINKER_INITIALIZED);
+
namespace chromeos {
// static
@@ -66,7 +70,7 @@ void SignedSettingsTempStorage::Finalize(PrefService* local_state) {
temp_storage->GetStringWithoutPathExpansion(*it, &value);
SignedSettings::CreateStorePropertyOp(
*it, value,
- Singleton< SignedSettings::Delegate<bool> >::get())->Execute();
+ g_signed_settings_delegate.Pointer())->Execute();
}
local_state->ClearPref(prefs::kSignedSettingsTempStorage);
}
diff --git a/chrome/browser/chromeos/usb_mount_observer.cc b/chrome/browser/chromeos/usb_mount_observer.cc
index 2f1e7a4..e63718f 100644
--- a/chrome/browser/chromeos/usb_mount_observer.cc
+++ b/chrome/browser/chromeos/usb_mount_observer.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/usb_mount_observer.h"
#include "base/command_line.h"
+#include "base/singleton.h"
#include "chrome/browser/dom_ui/filebrowse_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -23,6 +24,11 @@ const int kPopupTop = 0;
const int kPopupWidth = 250;
const int kPopupHeight = 300;
+// static
+USBMountObserver* USBMountObserver::Get() {
+ return Singleton<USBMountObserver>::get();
+}
+
void USBMountObserver::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/chromeos/usb_mount_observer.h b/chrome/browser/chromeos/usb_mount_observer.h
index 5f30b31..66ab2bf 100644
--- a/chrome/browser/chromeos/usb_mount_observer.h
+++ b/chrome/browser/chromeos/usb_mount_observer.h
@@ -16,6 +16,7 @@
#include "chrome/common/notification_type.h"
class Browser;
+template <typename T> struct DefaultSingletonTraits;
class Profile;
namespace chromeos { // NOLINT
@@ -31,12 +32,8 @@ class USBMountObserver : public chromeos::MountLibrary::Observer,
std::string mount_path;
};
- USBMountObserver() {}
- ~USBMountObserver() {}
+ static USBMountObserver* Get();
- static USBMountObserver* Get() {
- return Singleton<USBMountObserver>::get();
- }
void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
@@ -48,9 +45,13 @@ class USBMountObserver : public chromeos::MountLibrary::Observer,
void ScanForDevices(chromeos::MountLibrary* obj);
private:
+ friend struct DefaultSingletonTraits<USBMountObserver>;
typedef std::vector<BrowserWithPath>::iterator BrowserIterator;
BrowserIterator FindBrowserForPath(const std::string& path);
+ USBMountObserver() {}
+ ~USBMountObserver() {}
+
void RemoveBrowserFromVector(const std::string& path);
// Used to create a window of a standard size, and add it to a list
diff --git a/chrome/browser/chromeos/volume_bubble.cc b/chrome/browser/chromeos/volume_bubble.cc
index f1850be..0846885 100644
--- a/chrome/browser/chromeos/volume_bubble.cc
+++ b/chrome/browser/chromeos/volume_bubble.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/volume_bubble.h"
#include "app/resource_bundle.h"
+#include "base/singleton.h"
#include "grit/theme_resources.h"
namespace chromeos {
@@ -19,4 +20,9 @@ VolumeBubble::VolumeBubble()
IDR_VOLUME_BUBBLE_MUTE_ICON)) {
}
+// static
+VolumeBubble* VolumeBubble::instance() {
+ return Singleton<VolumeBubble>::get();
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/volume_bubble.h b/chrome/browser/chromeos/volume_bubble.h
index 9d0ee57..a99ae2c 100644
--- a/chrome/browser/chromeos/volume_bubble.h
+++ b/chrome/browser/chromeos/volume_bubble.h
@@ -6,17 +6,16 @@
#define CHROME_BROWSER_CHROMEOS_VOLUME_BUBBLE_H_
#pragma once
-#include "base/singleton.h"
#include "chrome/browser/chromeos/setting_level_bubble.h"
+template <typename T> struct DefaultSingletonTraits;
+
namespace chromeos {
// Singleton class controlling volume bubble.
class VolumeBubble : public SettingLevelBubble {
public:
- static VolumeBubble* instance() {
- return Singleton<VolumeBubble>::get();
- }
+ static VolumeBubble* instance();
private:
friend struct DefaultSingletonTraits<VolumeBubble>;