summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ceee/ie/broker/api_dispatcher.cc33
-rw-r--r--ceee/ie/broker/api_dispatcher.h6
-rw-r--r--ceee/ie/broker/broker.cc5
-rw-r--r--ceee/ie/broker/broker_module.cc3
-rw-r--r--ceee/ie/broker/chrome_postman.cc10
-rw-r--r--ceee/ie/broker/executors_manager.cc5
-rw-r--r--ceee/ie/broker/executors_manager.h5
-rw-r--r--ceee/ie/broker/tab_api_module.cc7
-rw-r--r--ceee/ie/plugin/bho/cookie_accountant.cc7
-rw-r--r--ceee/ie/plugin/bho/cookie_accountant.h6
-rw-r--r--ceee/ie/plugin/bho/web_progress_notifier.cc2
-rw-r--r--ceee/ie/plugin/bho/webrequest_notifier.cc25
-rw-r--r--ceee/ie/plugin/bho/webrequest_notifier.h7
-rw-r--r--chrome/browser/gpu_process_host.cc2
-rw-r--r--chrome/browser/plugin_process_host.cc2
-rw-r--r--chrome/browser/renderer_host/resource_message_filter_gtk.cc8
-rw-r--r--chrome/gpu/gpu_channel.cc4
-rw-r--r--chrome/gpu/gpu_video_service.cc5
-rw-r--r--chrome/gpu/gpu_video_service.h5
-rw-r--r--chrome/renderer/automation/dom_automation_v8_extension.cc2
-rw-r--r--chrome/renderer/extensions/bindings_utils.cc14
-rw-r--r--chrome/renderer/extensions/bindings_utils.h15
-rw-r--r--chrome/renderer/extensions/event_bindings.cc2
-rw-r--r--chrome/renderer/extensions/extension_api_json_validity_unittest.cc2
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc4
-rw-r--r--chrome/renderer/extensions/js_only_v8_extensions.cc6
-rw-r--r--chrome/renderer/extensions/renderer_extension_bindings.cc2
-rw-r--r--chrome/test/webdriver/commands/create_session.cc2
-rw-r--r--chrome/test/webdriver/commands/session_with_id.cc2
-rw-r--r--chrome/test/webdriver/commands/webdriver_command.cc2
-rw-r--r--chrome/test/webdriver/server.cc3
-rw-r--r--chrome/test/webdriver/session_manager.cc5
-rw-r--r--chrome/test/webdriver/session_manager.h3
-rw-r--r--chrome_frame/chrome_tab.cc4
-rw-r--r--chrome_frame/dll_redirector.cc5
-rw-r--r--chrome_frame/dll_redirector.h3
-rw-r--r--chrome_frame/policy_settings.cc4
-rw-r--r--chrome_frame/policy_settings.h18
-rw-r--r--chrome_frame/protocol_sink_wrap.cc5
-rw-r--r--chrome_frame/simple_resource_loader.cc10
-rw-r--r--chrome_frame/simple_resource_loader.h4
-rw-r--r--chrome_frame/test/policy_settings_unittest.cc90
-rw-r--r--chrome_frame/utils.cc9
-rw-r--r--gfx/gtk_native_view_id_manager.cc5
-rw-r--r--gfx/gtk_native_view_id_manager.h6
-rw-r--r--gfx/native_widget_types_gtk.cc2
-rw-r--r--media/filters/ffmpeg_demuxer.cc4
-rw-r--r--media/filters/ffmpeg_glue.cc7
-rw-r--r--media/filters/ffmpeg_glue.h5
-rw-r--r--media/filters/ffmpeg_glue_unittest.cc12
-rw-r--r--views/focus/focus_manager.cc5
-rw-r--r--views/focus/focus_manager.h4
-rw-r--r--webkit/glue/plugins/pepper_resource_tracker.cc5
-rw-r--r--webkit/glue/plugins/pepper_resource_tracker.h4
54 files changed, 247 insertions, 175 deletions
diff --git a/ceee/ie/broker/api_dispatcher.cc b/ceee/ie/broker/api_dispatcher.cc
index 6590379..b0917a2 100644
--- a/ceee/ie/broker/api_dispatcher.cc
+++ b/ceee/ie/broker/api_dispatcher.cc
@@ -142,26 +142,23 @@ void ApiDispatcher::FireEvent(const char* event_name, const char* event_args) {
void ApiDispatcher::GetExecutor(HWND window, REFIID iid, void** executor) {
DWORD thread_id = ::GetWindowThreadProcessId(window, NULL);
- HRESULT hr = Singleton<ExecutorsManager,
- ExecutorsManager::SingletonTraits>::get()->
- GetExecutor(thread_id, window, iid, executor);
+ HRESULT hr = ExecutorsManager::GetInstance()->GetExecutor(thread_id, window,
+ iid, executor);
DLOG_IF(INFO, FAILED(hr)) << "Failed to get executor for window: " <<
window << ". In thread: " << thread_id << ". " << com::LogHr(hr);
}
bool ApiDispatcher::IsTabIdValid(int tab_id) const {
- return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- IsTabIdValid(tab_id);
+ return ExecutorsManager::GetInstance()->IsTabIdValid(tab_id);
}
HWND ApiDispatcher::GetTabHandleFromId(int tab_id) const {
- return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- GetTabHandleFromId(tab_id);
+ return ExecutorsManager::GetInstance()->GetTabHandleFromId(tab_id);
}
HWND ApiDispatcher::GetTabHandleFromToolBandId(int tool_band_id) const {
- return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- GetTabHandleFromToolBandId(tool_band_id);
+ return ExecutorsManager::GetInstance()->GetTabHandleFromToolBandId(
+ tool_band_id);
}
HWND ApiDispatcher::GetWindowHandleFromId(int window_id) const {
@@ -169,13 +166,11 @@ HWND ApiDispatcher::GetWindowHandleFromId(int window_id) const {
}
bool ApiDispatcher::IsTabHandleValid(HWND tab_handle) const {
- return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- IsTabHandleValid(tab_handle);
+ return ExecutorsManager::GetInstance()->IsTabHandleValid(tab_handle);
}
int ApiDispatcher::GetTabIdFromHandle(HWND tab_handle) const {
- return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- GetTabIdFromHandle(tab_handle);
+ return ExecutorsManager::GetInstance()->GetTabIdFromHandle(tab_handle);
}
int ApiDispatcher::GetWindowIdFromHandle(HWND window_handle) const {
@@ -183,8 +178,7 @@ int ApiDispatcher::GetWindowIdFromHandle(HWND window_handle) const {
}
void ApiDispatcher::DeleteTabHandle(HWND handle) {
- Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- DeleteTabHandle(handle);
+ ExecutorsManager::GetInstance()->DeleteTabHandle(handle);
}
void ApiDispatcher::RegisterInvocation(const char* function_name,
@@ -297,11 +291,11 @@ const Value* ApiDispatcher::InvocationResult::GetValue(const char* name) {
}
ApiDispatcher* ApiDispatcher::InvocationResult::GetDispatcher() {
- return ProductionApiDispatcher::get();
+ return ProductionApiDispatcher::GetInstance();
}
ApiDispatcher* ApiDispatcher::Invocation::GetDispatcher() {
- return ProductionApiDispatcher::get();
+ return ProductionApiDispatcher::GetInstance();
}
// Function registration preprocessor magic. See api_registration.h for details.
@@ -322,3 +316,8 @@ ApiDispatcher* ApiDispatcher::Invocation::GetDispatcher() {
ProductionApiDispatcher::ProductionApiDispatcher() {
REGISTER_ALL_API_FUNCTIONS();
}
+
+// static
+ProductionApiDispatcher* ProductionApiDispatcher::GetInstance() {
+ return Singleton<ProductionApiDispatcher>::get();
+}
diff --git a/ceee/ie/broker/api_dispatcher.h b/ceee/ie/broker/api_dispatcher.h
index 6f6a86a..ce51dfb 100644
--- a/ceee/ie/broker/api_dispatcher.h
+++ b/ceee/ie/broker/api_dispatcher.h
@@ -307,8 +307,10 @@ ApiDispatcher::Invocation* NewApiInvocation() {
// A singleton that initializes and keeps the ApiDispatcher used by production
// code.
-class ProductionApiDispatcher : public ApiDispatcher,
- public Singleton<ProductionApiDispatcher> {
+class ProductionApiDispatcher : public ApiDispatcher {
+ public:
+ static ProductionApiDispatcher* GetInstance();
+
private:
// This ensures no construction is possible outside of the class itself.
friend struct DefaultSingletonTraits<ProductionApiDispatcher>;
diff --git a/ceee/ie/broker/broker.cc b/ceee/ie/broker/broker.cc
index 36e8bc8..65ea376 100644
--- a/ceee/ie/broker/broker.cc
+++ b/ceee/ie/broker/broker.cc
@@ -16,9 +16,8 @@
HRESULT CeeeBroker::FinalConstruct() {
// So that we get a pointer to the ExecutorsManager and let tests override it.
- executors_manager_ = Singleton<ExecutorsManager,
- ExecutorsManager::SingletonTraits>::get();
- api_dispatcher_ = ProductionApiDispatcher::get();
+ executors_manager_ = ExecutorsManager::GetInstance();
+ api_dispatcher_ = ProductionApiDispatcher::GetInstance();
return S_OK;
}
diff --git a/ceee/ie/broker/broker_module.cc b/ceee/ie/broker/broker_module.cc
index 252e6a4..6728c06 100644
--- a/ceee/ie/broker/broker_module.cc
+++ b/ceee/ie/broker/broker_module.cc
@@ -197,8 +197,7 @@ HRESULT CeeeBrokerModule::PostMessageLoop() {
void CeeeBrokerModule::TearDown() {
rpc_server_.Stop();
- Singleton<ExecutorsManager,
- ExecutorsManager::SingletonTraits>()->Terminate();
+ ExecutorsManager::GetInstance()->Terminate();
WindowEventsFunnel::Terminate();
// Upload data if necessary.
diff --git a/ceee/ie/broker/chrome_postman.cc b/ceee/ie/broker/chrome_postman.cc
index 9a9562d..430446a 100644
--- a/ceee/ie/broker/chrome_postman.cc
+++ b/ceee/ie/broker/chrome_postman.cc
@@ -60,7 +60,7 @@ class ApiExecutionTask : public Task {
explicit ApiExecutionTask(BSTR message) : message_(message) {}
virtual void Run() {
- ProductionApiDispatcher::get()->HandleApiRequest(message_, NULL);
+ ProductionApiDispatcher::GetInstance()->HandleApiRequest(message_, NULL);
}
private:
CComBSTR message_;
@@ -72,8 +72,8 @@ class FireEventTask : public Task {
: event_name_(event_name), event_args_(event_args) {}
virtual void Run() {
- ProductionApiDispatcher::get()->FireEvent(event_name_.c_str(),
- event_args_.c_str());
+ ProductionApiDispatcher::GetInstance()->FireEvent(event_name_.c_str(),
+ event_args_.c_str());
}
private:
std::string event_name_;
@@ -318,11 +318,11 @@ ChromePostman::ApiInvocationWorkerThread::ApiInvocationWorkerThread()
void ChromePostman::ApiInvocationWorkerThread::Init() {
::CoInitializeEx(0, COINIT_MULTITHREADED);
- ProductionApiDispatcher::get()->SetApiInvocationThreadId(
+ ProductionApiDispatcher::GetInstance()->SetApiInvocationThreadId(
::GetCurrentThreadId());
}
void ChromePostman::ApiInvocationWorkerThread::CleanUp() {
::CoUninitialize();
- ProductionApiDispatcher::get()->SetApiInvocationThreadId(0);
+ ProductionApiDispatcher::GetInstance()->SetApiInvocationThreadId(0);
}
diff --git a/ceee/ie/broker/executors_manager.cc b/ceee/ie/broker/executors_manager.cc
index a221eb6..4e2c32d 100644
--- a/ceee/ie/broker/executors_manager.cc
+++ b/ceee/ie/broker/executors_manager.cc
@@ -69,6 +69,11 @@ ExecutorsManager::ExecutorsManager(bool no_thread)
}
}
+// static
+ExecutorsManager* ExecutorsManager::GetInstance() {
+ return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get();
+}
+
bool ExecutorsManager::IsKnownWindow(HWND window) {
return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
IsKnownWindowImpl(window);
diff --git a/ceee/ie/broker/executors_manager.h b/ceee/ie/broker/executors_manager.h
index 48a15f9..48925d5 100644
--- a/ceee/ie/broker/executors_manager.h
+++ b/ceee/ie/broker/executors_manager.h
@@ -34,6 +34,9 @@ class ExecutorsManager {
// Identifiers for destination threads where to run executors.
typedef DWORD ThreadId;
+ // Returns the singleton instance.
+ static ExecutorsManager* GetInstance();
+
// To avoid lint errors, even though we are only virtual for unittests.
virtual ~ExecutorsManager() {}
@@ -125,6 +128,7 @@ class ExecutorsManager {
// thread id.
virtual void CleanupMapsForThread(DWORD thread_id);
+ protected:
// Traits for Singleton<ExecutorsManager> so that we can pass an argument
// to the constructor.
struct SingletonTraits : public DefaultSingletonTraits<ExecutorsManager> {
@@ -136,7 +140,6 @@ class ExecutorsManager {
}
};
- protected:
// The data we pass to start our worker thread.
// THERE IS A COPY OF THIS CLASS IN THE UNITTEST WHICH YOU NEED TO UPDATE IF
// you change this one...
diff --git a/ceee/ie/broker/tab_api_module.cc b/ceee/ie/broker/tab_api_module.cc
index c2ac61f..49f92b5 100644
--- a/ceee/ie/broker/tab_api_module.cc
+++ b/ceee/ie/broker/tab_api_module.cc
@@ -153,8 +153,7 @@ bool CeeeMapTabIdToHandle(const std::string& input_args,
int tab_id = kInvalidChromeSessionId;
HWND tab_handle = NULL;
if (GetIdAndHandleFromArgs(input_args, &tab_id, &tab_handle)) {
- Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- SetTabIdForHandle(tab_id, tab_handle);
+ ExecutorsManager::GetInstance()->SetTabIdForHandle(tab_id, tab_handle);
return true;
}
return false;
@@ -166,8 +165,8 @@ bool CeeeMapToolbandIdToHandle(const std::string& input_args,
int toolband_id = kInvalidChromeSessionId;
HWND tab_handle = NULL;
if (GetIdAndHandleFromArgs(input_args, &toolband_id, &tab_handle)) {
- Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
- SetTabToolBandIdForHandle(toolband_id, tab_handle);
+ ExecutorsManager::GetInstance()->SetTabToolBandIdForHandle(toolband_id,
+ tab_handle);
return true;
}
return false;
diff --git a/ceee/ie/plugin/bho/cookie_accountant.cc b/ceee/ie/plugin/bho/cookie_accountant.cc
index 1da3256..3d0f3f1 100644
--- a/ceee/ie/plugin/bho/cookie_accountant.cc
+++ b/ceee/ie/plugin/bho/cookie_accountant.cc
@@ -44,10 +44,15 @@ CookieAccountant::~CookieAccountant() {
ProductionCookieAccountant::ProductionCookieAccountant() {
}
+// static
+ProductionCookieAccountant* ProductionCookieAccountant::GetInstance() {
+ return Singleton<ProductionCookieAccountant>::get();
+}
+
CookieAccountant* CookieAccountant::GetInstance() {
// Unit tests can set singleton_instance_ directly.
if (singleton_instance_ == NULL)
- singleton_instance_ = ProductionCookieAccountant::get();
+ singleton_instance_ = ProductionCookieAccountant::GetInstance();
return singleton_instance_;
}
diff --git a/ceee/ie/plugin/bho/cookie_accountant.h b/ceee/ie/plugin/bho/cookie_accountant.h
index 8e7423b..a2b9de3 100644
--- a/ceee/ie/plugin/bho/cookie_accountant.h
+++ b/ceee/ie/plugin/bho/cookie_accountant.h
@@ -125,8 +125,10 @@ class CookieAccountant {
// A singleton that initializes and keeps the CookieAccountant used by
// production code. This class is separate so that CookieAccountant can still
// be accessed for unit testing.
-class ProductionCookieAccountant : public CookieAccountant,
- public Singleton<ProductionCookieAccountant> {
+class ProductionCookieAccountant : public CookieAccountant {
+ public:
+ static ProductionCookieAccountant* GetInstance();
+
private:
// This ensures no construction is possible outside of the class itself.
friend struct DefaultSingletonTraits<ProductionCookieAccountant>;
diff --git a/ceee/ie/plugin/bho/web_progress_notifier.cc b/ceee/ie/plugin/bho/web_progress_notifier.cc
index 567c543..0984f4d1 100644
--- a/ceee/ie/plugin/bho/web_progress_notifier.cc
+++ b/ceee/ie/plugin/bho/web_progress_notifier.cc
@@ -339,7 +339,7 @@ WebNavigationEventsFunnel* WebProgressNotifier::webnavigation_events_funnel() {
WebRequestNotifier* WebProgressNotifier::webrequest_notifier() {
if (cached_webrequest_notifier_ == NULL) {
- cached_webrequest_notifier_ = ProductionWebRequestNotifier::get();
+ cached_webrequest_notifier_ = ProductionWebRequestNotifier::GetInstance();
}
return cached_webrequest_notifier_;
}
diff --git a/ceee/ie/plugin/bho/webrequest_notifier.cc b/ceee/ie/plugin/bho/webrequest_notifier.cc
index 5f65a8b..c0487a3 100644
--- a/ceee/ie/plugin/bho/webrequest_notifier.cc
+++ b/ceee/ie/plugin/bho/webrequest_notifier.cc
@@ -162,7 +162,7 @@ INTERNET_STATUS_CALLBACK STDAPICALLTYPE
WebRequestNotifier::InternetSetStatusCallbackAPatch(
HINTERNET internet,
INTERNET_STATUS_CALLBACK callback) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
INTERNET_STATUS_CALLBACK new_callback =
instance->HandleBeforeInternetSetStatusCallback(internet, callback);
return ::InternetSetStatusCallbackA(internet, new_callback);
@@ -172,7 +172,7 @@ INTERNET_STATUS_CALLBACK STDAPICALLTYPE
WebRequestNotifier::InternetSetStatusCallbackWPatch(
HINTERNET internet,
INTERNET_STATUS_CALLBACK callback) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
INTERNET_STATUS_CALLBACK new_callback =
instance->HandleBeforeInternetSetStatusCallback(internet, callback);
return ::InternetSetStatusCallbackW(internet, new_callback);
@@ -187,7 +187,7 @@ HINTERNET STDAPICALLTYPE WebRequestNotifier::InternetConnectAPatch(
DWORD service,
DWORD flags,
DWORD_PTR context) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleBeforeInternetConnect(internet);
HINTERNET server = ::InternetConnectA(internet, server_name, server_port,
@@ -208,7 +208,7 @@ HINTERNET STDAPICALLTYPE WebRequestNotifier::InternetConnectWPatch(
DWORD service,
DWORD flags,
DWORD_PTR context) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleBeforeInternetConnect(internet);
HINTERNET server = ::InternetConnectW(internet, server_name, server_port,
@@ -233,7 +233,7 @@ HINTERNET STDAPICALLTYPE WebRequestNotifier::HttpOpenRequestAPatch(
referrer, accept_types, flags,
context);
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleAfterHttpOpenRequest(connect, request, verb,
CA2W(object_name), flags);
return request;
@@ -252,7 +252,7 @@ HINTERNET STDAPICALLTYPE WebRequestNotifier::HttpOpenRequestWPatch(
referrer, accept_types, flags,
context);
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleAfterHttpOpenRequest(connect, request, CW2A(verb),
object_name, flags);
return request;
@@ -264,7 +264,7 @@ BOOL STDAPICALLTYPE WebRequestNotifier::HttpSendRequestAPatch(
DWORD headers_length,
LPVOID optional,
DWORD optional_length) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleBeforeHttpSendRequest(request);
return ::HttpSendRequestA(request, headers, headers_length, optional,
optional_length);
@@ -276,7 +276,7 @@ BOOL STDAPICALLTYPE WebRequestNotifier::HttpSendRequestWPatch(
DWORD headers_length,
LPVOID optional,
DWORD optional_length) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleBeforeHttpSendRequest(request);
return ::HttpSendRequestW(request, headers, headers_length, optional,
optional_length);
@@ -289,7 +289,7 @@ void CALLBACK WebRequestNotifier::InternetStatusCallbackPatch(
DWORD internet_status,
LPVOID status_information,
DWORD status_information_length) {
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleBeforeInternetStatusCallback(original, internet, context,
internet_status,
status_information,
@@ -305,7 +305,7 @@ BOOL STDAPICALLTYPE WebRequestNotifier::InternetReadFilePatch(
LPDWORD number_of_bytes_read) {
BOOL result = ::InternetReadFile(file, buffer, number_of_bytes_to_read,
number_of_bytes_read);
- WebRequestNotifier* instance = ProductionWebRequestNotifier::get();
+ WebRequestNotifier* instance = ProductionWebRequestNotifier::GetInstance();
instance->HandleAfterInternetReadFile(file, result, number_of_bytes_read);
return result;
@@ -813,3 +813,8 @@ void WebRequestNotifier::TransitRequestToNextState(
}
info->state = next_state;
}
+
+// static
+ProductionWebRequestNotifier* ProductionWebRequestNotifier::GetInstance() {
+ return Singleton<ProductionWebRequestNotifier>::get();
+}
diff --git a/ceee/ie/plugin/bho/webrequest_notifier.h b/ceee/ie/plugin/bho/webrequest_notifier.h
index 0676bf65..d7c1227 100644
--- a/ceee/ie/plugin/bho/webrequest_notifier.h
+++ b/ceee/ie/plugin/bho/webrequest_notifier.h
@@ -443,9 +443,10 @@ class WebRequestNotifier {
};
// A singleton that keeps the WebRequestNotifier used by production code.
-class ProductionWebRequestNotifier
- : public WebRequestNotifier,
- public Singleton<ProductionWebRequestNotifier> {
+class ProductionWebRequestNotifier : public WebRequestNotifier {
+ public:
+ static ProductionWebRequestNotifier* GetInstance();
+
private:
ProductionWebRequestNotifier() {}
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc
index abc8273..dd40b005 100644
--- a/chrome/browser/gpu_process_host.cc
+++ b/chrome/browser/gpu_process_host.cc
@@ -222,7 +222,7 @@ void SendDelayedReply(IPC::Message* reply_msg) {
void GetViewXIDDispatcher(gfx::NativeViewId id, IPC::Message* reply_msg) {
XID xid;
- GtkNativeViewManager* manager = Singleton<GtkNativeViewManager>::get();
+ GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
if (!manager->GetPermanentXIDForId(&xid, id)) {
DLOG(ERROR) << "Can't find XID for view id " << id;
xid = 0;
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index a87fdd6..c6ee524 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -87,7 +87,7 @@ void PluginProcessHost::AddWindow(HWND window) {
void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id,
gfx::PluginWindowHandle* output) {
*output = 0;
- Singleton<GtkNativeViewManager>()->GetXIDForId(output, id);
+ GtkNativeViewManager::GetInstance()->GetXIDForId(output, id);
}
#endif // defined(TOOLKIT_USES_GTK)
diff --git a/chrome/browser/renderer_host/resource_message_filter_gtk.cc b/chrome/browser/renderer_host/resource_message_filter_gtk.cc
index 59c6588..e2bf641 100644
--- a/chrome/browser/renderer_host/resource_message_filter_gtk.cc
+++ b/chrome/browser/renderer_host/resource_message_filter_gtk.cc
@@ -69,8 +69,8 @@ void ResourceMessageFilter::DoOnGetWindowRect(gfx::NativeViewId view,
gfx::Rect rect;
XID window;
- AutoLock lock(Singleton<GtkNativeViewManager>()->unrealize_lock());
- if (Singleton<GtkNativeViewManager>()->GetXIDForId(&window, view)) {
+ AutoLock lock(GtkNativeViewManager::GetInstance()->unrealize_lock());
+ if (GtkNativeViewManager::GetInstance()->GetXIDForId(&window, view)) {
if (window) {
int x, y;
unsigned width, height;
@@ -109,8 +109,8 @@ void ResourceMessageFilter::DoOnGetRootWindowRect(gfx::NativeViewId view,
gfx::Rect rect;
XID window;
- AutoLock lock(Singleton<GtkNativeViewManager>()->unrealize_lock());
- if (Singleton<GtkNativeViewManager>()->GetXIDForId(&window, view)) {
+ AutoLock lock(GtkNativeViewManager::GetInstance()->unrealize_lock());
+ if (GtkNativeViewManager::GetInstance()->GetXIDForId(&window, view)) {
if (window) {
const XID toplevel = GetTopLevelWindow(window);
if (toplevel) {
diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc
index 10641ed..9d3ebd3 100644
--- a/chrome/gpu/gpu_channel.cc
+++ b/chrome/gpu/gpu_channel.cc
@@ -206,7 +206,7 @@ void GpuChannel::OnCreateVideoDecoder(int32 context_route_id,
int32 decoder_host_id) {
#if defined(ENABLE_GPU)
VLOG(1) << "GpuChannel::OnCreateVideoDecoder";
- GpuVideoService* service = GpuVideoService::get();
+ GpuVideoService* service = GpuVideoService::GetInstance();
if (service == NULL) {
// TODO(hclam): Need to send a failure message.
return;
@@ -228,7 +228,7 @@ void GpuChannel::OnCreateVideoDecoder(int32 context_route_id,
void GpuChannel::OnDestroyVideoDecoder(int32 decoder_id) {
#if defined(ENABLE_GPU)
LOG(ERROR) << "GpuChannel::OnDestroyVideoDecoder";
- GpuVideoService* service = GpuVideoService::get();
+ GpuVideoService* service = GpuVideoService::GetInstance();
if (service == NULL)
return;
service->DestroyVideoDecoder(&router_, decoder_id);
diff --git a/chrome/gpu/gpu_video_service.cc b/chrome/gpu/gpu_video_service.cc
index 03025b8..ca9d482 100644
--- a/chrome/gpu/gpu_video_service.cc
+++ b/chrome/gpu/gpu_video_service.cc
@@ -23,6 +23,11 @@ GpuVideoService::~GpuVideoService() {
UnintializeGpuVideoService();
}
+// static
+GpuVideoService* GpuVideoService::GetInstance() {
+ return Singleton<GpuVideoService>::get();
+}
+
void GpuVideoService::OnChannelConnected(int32 peer_pid) {
LOG(ERROR) << "GpuVideoService::OnChannelConnected";
}
diff --git a/chrome/gpu/gpu_video_service.h b/chrome/gpu/gpu_video_service.h
index e6af444..b9ad6da 100644
--- a/chrome/gpu/gpu_video_service.h
+++ b/chrome/gpu/gpu_video_service.h
@@ -14,9 +14,10 @@
class GpuChannel;
-class GpuVideoService : public IPC::Channel::Listener,
- public Singleton<GpuVideoService> {
+class GpuVideoService : public IPC::Channel::Listener {
public:
+ static GpuVideoService* GetInstance();
+
// IPC::Channel::Listener.
virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelError();
diff --git a/chrome/renderer/automation/dom_automation_v8_extension.cc b/chrome/renderer/automation/dom_automation_v8_extension.cc
index efe5ada..258c874 100644
--- a/chrome/renderer/automation/dom_automation_v8_extension.cc
+++ b/chrome/renderer/automation/dom_automation_v8_extension.cc
@@ -14,6 +14,6 @@ const char* DomAutomationV8Extension::kName = "chrome/domautomation";
v8::Extension* DomAutomationV8Extension::Get() {
static v8::Extension* extension =
new bindings_utils::ExtensionBase(
- kName, GetStringResource<IDR_DOM_AUTOMATION_JS>(), 0, NULL);
+ kName, GetStringResource(IDR_DOM_AUTOMATION_JS), 0, NULL);
return extension;
}
diff --git a/chrome/renderer/extensions/bindings_utils.cc b/chrome/renderer/extensions/bindings_utils.cc
index 83ddeee..5b213c4 100644
--- a/chrome/renderer/extensions/bindings_utils.cc
+++ b/chrome/renderer/extensions/bindings_utils.cc
@@ -22,6 +22,20 @@ struct SingletonData {
PendingRequestMap pending_requests;
};
+typedef std::map<int, std::string> StringMap;
+
+const char* GetStringResource(int resource_id) {
+ StringMap* strings = Singleton<StringMap>::get();
+ StringMap::iterator it = strings->find(resource_id);
+ if (it == strings->end()) {
+ it = strings->insert(std::make_pair(
+ resource_id,
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ resource_id).as_string())).first;
+ }
+ return it->second.c_str();
+}
+
// ExtensionBase
v8::Handle<v8::FunctionTemplate>
diff --git a/chrome/renderer/extensions/bindings_utils.h b/chrome/renderer/extensions/bindings_utils.h
index d1bc3b3..f506ce0 100644
--- a/chrome/renderer/extensions/bindings_utils.h
+++ b/chrome/renderer/extensions/bindings_utils.h
@@ -50,20 +50,7 @@ class ExtensionBase : public v8::Extension {
static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args);
};
-template<int kResourceId>
-struct StringResourceTemplate {
- StringResourceTemplate()
- : resource(ResourceBundle::GetSharedInstance().GetRawDataResource(
- kResourceId).as_string()) {
- }
- std::string resource;
-};
-
-template<int kResourceId>
-const char* GetStringResource() {
- return
- Singleton< StringResourceTemplate<kResourceId> >::get()->resource.c_str();
-}
+const char* GetStringResource(int resource_id);
// Contains information about a single javascript context.
struct ContextInfo {
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index 60c5c0d..d960509 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -72,7 +72,7 @@ class ExtensionImpl : public ExtensionBase {
public:
ExtensionImpl()
: ExtensionBase(EventBindings::kName,
- GetStringResource<IDR_EVENT_BINDINGS_JS>(),
+ GetStringResource(IDR_EVENT_BINDINGS_JS),
0, NULL) {
}
~ExtensionImpl() {}
diff --git a/chrome/renderer/extensions/extension_api_json_validity_unittest.cc b/chrome/renderer/extensions/extension_api_json_validity_unittest.cc
index b692649..49858f2 100644
--- a/chrome/renderer/extensions/extension_api_json_validity_unittest.cc
+++ b/chrome/renderer/extensions/extension_api_json_validity_unittest.cc
@@ -130,7 +130,7 @@ TEST_F(ExtensionApiJsonValidityTest, Basic) {
// chrome/renderer/resources/extension_process_bindings.js .
TEST_F(ExtensionApiJsonValidityTest, MAYBE_WithV8) {
std::string ext_api_string =
- bindings_utils::GetStringResource<IDR_EXTENSION_API_JSON>();
+ bindings_utils::GetStringResource(IDR_EXTENSION_API_JSON);
// Create a global variable holding the text of extension_api.json .
SetGlobalStringVar("ext_api_json_text", ext_api_string);
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 6631587..7370e3d 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -194,7 +194,7 @@ class ExtensionViewAccumulator : public RenderViewVisitor {
class ExtensionImpl : public ExtensionBase {
public:
ExtensionImpl() : ExtensionBase(
- kExtensionName, GetStringResource<IDR_EXTENSION_PROCESS_BINDINGS_JS>(),
+ kExtensionName, GetStringResource(IDR_EXTENSION_PROCESS_BINDINGS_JS),
arraysize(kExtensionDeps), kExtensionDeps) {}
static void SetFunctionNames(const std::vector<std::string>& names) {
@@ -253,7 +253,7 @@ class ExtensionImpl : public ExtensionBase {
private:
static v8::Handle<v8::Value> GetExtensionAPIDefinition(
const v8::Arguments& args) {
- return v8::String::New(GetStringResource<IDR_EXTENSION_API_JSON>());
+ return v8::String::New(GetStringResource(IDR_EXTENSION_API_JSON));
}
static v8::Handle<v8::Value> PopupViewFinder(
diff --git a/chrome/renderer/extensions/js_only_v8_extensions.cc b/chrome/renderer/extensions/js_only_v8_extensions.cc
index 359e756..2549cc3 100644
--- a/chrome/renderer/extensions/js_only_v8_extensions.cc
+++ b/chrome/renderer/extensions/js_only_v8_extensions.cc
@@ -14,7 +14,7 @@ const char* BaseJsV8Extension::kName = "chrome/base";
v8::Extension* BaseJsV8Extension::Get() {
static v8::Extension* extension =
new bindings_utils::ExtensionBase(
- kName, GetStringResource<IDR_BASE_JS>(), 0, NULL);
+ kName, GetStringResource(IDR_BASE_JS), 0, NULL);
return extension;
}
@@ -23,7 +23,7 @@ const char* JsonSchemaJsV8Extension::kName = "chrome/jsonschema";
v8::Extension* JsonSchemaJsV8Extension::Get() {
static v8::Extension* extension =
new bindings_utils::ExtensionBase(
- kName, GetStringResource<IDR_JSON_SCHEMA_JS>(), 0, NULL);
+ kName, GetStringResource(IDR_JSON_SCHEMA_JS), 0, NULL);
return extension;
}
@@ -32,6 +32,6 @@ const char* ExtensionApiTestV8Extension::kName = "chrome/extensionapitest";
v8::Extension* ExtensionApiTestV8Extension::Get() {
static v8::Extension* extension =
new bindings_utils::ExtensionBase(
- kName, GetStringResource<IDR_EXTENSION_APITEST_JS>(), 0, NULL);
+ kName, GetStringResource(IDR_EXTENSION_APITEST_JS), 0, NULL);
return extension;
}
diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc
index d8fc4db..9555672 100644
--- a/chrome/renderer/extensions/renderer_extension_bindings.cc
+++ b/chrome/renderer/extensions/renderer_extension_bindings.cc
@@ -63,7 +63,7 @@ class ExtensionImpl : public ExtensionBase {
public:
ExtensionImpl()
: ExtensionBase(RendererExtensionBindings::kName,
- GetStringResource<IDR_RENDERER_EXTENSION_BINDINGS_JS>(),
+ GetStringResource(IDR_RENDERER_EXTENSION_BINDINGS_JS),
arraysize(kExtensionDeps), kExtensionDeps) {
}
~ExtensionImpl() {}
diff --git a/chrome/test/webdriver/commands/create_session.cc b/chrome/test/webdriver/commands/create_session.cc
index 30c71c7..7ba85a4 100644
--- a/chrome/test/webdriver/commands/create_session.cc
+++ b/chrome/test/webdriver/commands/create_session.cc
@@ -15,7 +15,7 @@
namespace webdriver {
void CreateSession::ExecutePost(Response* const response) {
- SessionManager* session_manager = Singleton<SessionManager>::get();
+ SessionManager* session_manager = SessionManager::GetInstance();
std::string session_id;
if (!session_manager->Create(&session_id)) {
diff --git a/chrome/test/webdriver/commands/session_with_id.cc b/chrome/test/webdriver/commands/session_with_id.cc
index e2dcced..682f5a2 100644
--- a/chrome/test/webdriver/commands/session_with_id.cc
+++ b/chrome/test/webdriver/commands/session_with_id.cc
@@ -41,7 +41,7 @@ void SessionWithID::ExecuteGet(Response* const response) {
}
void SessionWithID::ExecuteDelete(Response* const response) {
- Singleton<SessionManager>::get()->Delete(session_->id());
+ SessionManager::GetInstance()->Delete(session_->id());
response->set_status(kSuccess);
}
diff --git a/chrome/test/webdriver/commands/webdriver_command.cc b/chrome/test/webdriver/commands/webdriver_command.cc
index da1b601..206679e 100644
--- a/chrome/test/webdriver/commands/webdriver_command.cc
+++ b/chrome/test/webdriver/commands/webdriver_command.cc
@@ -51,7 +51,7 @@ bool WebDriverCommand::Init(Response* const response) {
}
VLOG(1) << "Fetching session: " << session_id;
- session_ = Singleton<SessionManager>::get()->GetSession(session_id);
+ session_ = SessionManager::GetInstance()->GetSession(session_id);
if (session_ == NULL) {
response->set_value(Value::CreateStringValue(
"Session not found: " + session_id));
diff --git a/chrome/test/webdriver/server.cc b/chrome/test/webdriver/server.cc
index ad496b1..8465f14 100644
--- a/chrome/test/webdriver/server.cc
+++ b/chrome/test/webdriver/server.cc
@@ -106,8 +106,7 @@ int main(int argc, char *argv[]) {
}
VLOG(1) << "Using port: " << port;
- webdriver::SessionManager* session =
- Singleton<webdriver::SessionManager>::get();
+ webdriver::SessionManager* session = webdriver::SessionManager::GetInstance();
session->SetIPAddress(port);
// Initialize SHTTPD context.
diff --git a/chrome/test/webdriver/session_manager.cc b/chrome/test/webdriver/session_manager.cc
index 6e49bb6..ab7db24 100644
--- a/chrome/test/webdriver/session_manager.cc
+++ b/chrome/test/webdriver/session_manager.cc
@@ -183,4 +183,9 @@ Session* SessionManager::GetSession(const std::string& id) const {
return it->second;
}
+// static
+SessionManager* SessionManager::GetInstance() {
+ return Singleton<SessionManager>::get();
+}
+
} // namespace webdriver
diff --git a/chrome/test/webdriver/session_manager.h b/chrome/test/webdriver/session_manager.h
index e93843f..91db207 100644
--- a/chrome/test/webdriver/session_manager.h
+++ b/chrome/test/webdriver/session_manager.h
@@ -21,6 +21,9 @@ namespace webdriver {
// their own profiles.
class SessionManager {
public:
+ // Returns the singleton instance.
+ static SessionManager* GetInstance();
+
std::string GetIPAddress();
bool SetIPAddress(const std::string& port);
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc
index a08f2b3..f3f4bd1 100644
--- a/chrome_frame/chrome_tab.cc
+++ b/chrome_frame/chrome_tab.cc
@@ -212,7 +212,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance,
logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE);
- DllRedirector* dll_redirector = Singleton<DllRedirector>::get();
+ DllRedirector* dll_redirector = DllRedirector::GetInstance();
DCHECK(dll_redirector);
if (!dll_redirector->RegisterAsFirstCFModule()) {
@@ -227,7 +227,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance,
// Enable ETW logging.
logging::LogEventProvider::Initialize(kChromeFrameProvider);
} else if (reason == DLL_PROCESS_DETACH) {
- DllRedirector* dll_redirector = Singleton<DllRedirector>::get();
+ DllRedirector* dll_redirector = DllRedirector::GetInstance();
DCHECK(dll_redirector);
dll_redirector->UnregisterAsFirstCFModule();
diff --git a/chrome_frame/dll_redirector.cc b/chrome_frame/dll_redirector.cc
index c6fe8cb..97143a7 100644
--- a/chrome_frame/dll_redirector.cc
+++ b/chrome_frame/dll_redirector.cc
@@ -46,6 +46,11 @@ DllRedirector::~DllRedirector() {
UnregisterAsFirstCFModule();
}
+// static
+DllRedirector* DllRedirector::GetInstance() {
+ return Singleton<DllRedirector>::get();
+}
+
bool DllRedirector::BuildSecurityAttributesForLock(
CSecurityAttributes* sec_attr) {
DCHECK(sec_attr);
diff --git a/chrome_frame/dll_redirector.h b/chrome_frame/dll_redirector.h
index be8a89b..1e12629 100644
--- a/chrome_frame/dll_redirector.h
+++ b/chrome_frame/dll_redirector.h
@@ -33,6 +33,9 @@ class Version;
// 3) The module this is compiled into is built with version info.
class DllRedirector {
public:
+ // Returns the singleton instance.
+ static DllRedirector* GetInstance();
+
virtual ~DllRedirector();
// Attempts to register this Chrome Frame version as the first loaded version
diff --git a/chrome_frame/policy_settings.cc b/chrome_frame/policy_settings.cc
index 1a35d67..50e465f 100644
--- a/chrome_frame/policy_settings.cc
+++ b/chrome_frame/policy_settings.cc
@@ -153,3 +153,7 @@ void PolicySettings::RefreshFromRegistry() {
swap(application_locale_, application_locale);
}
+// static
+PolicySettings* PolicySettings::GetInstance() {
+ return Singleton<PolicySettings>::get();
+}
diff --git a/chrome_frame/policy_settings.h b/chrome_frame/policy_settings.h
index 28182bd..72e32d2 100644
--- a/chrome_frame/policy_settings.h
+++ b/chrome_frame/policy_settings.h
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/singleton.h"
#include "base/basictypes.h"
@@ -21,12 +22,7 @@ class PolicySettings {
RENDER_IN_CHROME_FRAME,
};
- PolicySettings() : default_renderer_(RENDERER_NOT_SPECIFIED) {
- RefreshFromRegistry();
- }
-
- ~PolicySettings() {
- }
+ static PolicySettings* GetInstance();
RendererForUrl default_renderer() const {
return default_renderer_;
@@ -50,6 +46,13 @@ class PolicySettings {
static void ReadApplicationLocaleSetting(std::wstring* application_locale);
protected:
+ PolicySettings() : default_renderer_(RENDERER_NOT_SPECIFIED) {
+ RefreshFromRegistry();
+ }
+
+ ~PolicySettings() {
+ }
+
// Protected for now since the class is not thread safe.
void RefreshFromRegistry();
@@ -60,8 +63,9 @@ class PolicySettings {
std::wstring application_locale_;
private:
+ // This ensures no construction is possible outside of the class itself.
+ friend struct DefaultSingletonTraits<PolicySettings>;
DISALLOW_COPY_AND_ASSIGN(PolicySettings);
};
-
#endif // CHROME_FRAME_POLICY_SETTINGS_H_
diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc
index 0ea330f..64d9048 100644
--- a/chrome_frame/protocol_sink_wrap.cc
+++ b/chrome_frame/protocol_sink_wrap.cc
@@ -232,9 +232,8 @@ bool IsAdditionallySupportedContentType(const wchar_t* status_text) {
return true;
}
- Singleton<PolicySettings> policy;
- if (policy->GetRendererForContentType(status_text) ==
- PolicySettings::RENDER_IN_CHROME_FRAME) {
+ if (PolicySettings::GetInstance()->GetRendererForContentType(
+ status_text) == PolicySettings::RENDER_IN_CHROME_FRAME) {
return true;
}
diff --git a/chrome_frame/simple_resource_loader.cc b/chrome_frame/simple_resource_loader.cc
index 89a51d7..324c5ca 100644
--- a/chrome_frame/simple_resource_loader.cc
+++ b/chrome_frame/simple_resource_loader.cc
@@ -88,8 +88,9 @@ SimpleResourceLoader::SimpleResourceLoader()
std::vector<std::wstring> language_tags;
// First, try the locale dictated by policy and its fallback.
- PushBackWithFallbackIfAbsent(Singleton<PolicySettings>()->ApplicationLocale(),
- &language_tags);
+ PushBackWithFallbackIfAbsent(
+ PolicySettings::GetInstance()->ApplicationLocale(),
+ &language_tags);
// Next, try the thread, process, user, system languages.
GetPreferredLanguages(&language_tags);
@@ -115,6 +116,11 @@ SimpleResourceLoader::~SimpleResourceLoader() {
}
// static
+SimpleResourceLoader* SimpleResourceLoader::instance() {
+ return Singleton<SimpleResourceLoader>::get();
+}
+
+// static
void SimpleResourceLoader::GetPreferredLanguages(
std::vector<std::wstring>* language_tags) {
DCHECK(language_tags);
diff --git a/chrome_frame/simple_resource_loader.h b/chrome_frame/simple_resource_loader.h
index c749052..45d03ed 100644
--- a/chrome_frame/simple_resource_loader.h
+++ b/chrome_frame/simple_resource_loader.h
@@ -21,9 +21,7 @@
class SimpleResourceLoader {
public:
- static SimpleResourceLoader* instance() {
- return Singleton<SimpleResourceLoader>::get();
- }
+ static SimpleResourceLoader* instance();
// Returns the language tag for the active language.
static std::wstring GetLanguage();
diff --git a/chrome_frame/test/policy_settings_unittest.cc b/chrome_frame/test/policy_settings_unittest.cc
index 55a0b32..53c4df0 100644
--- a/chrome_frame/test/policy_settings_unittest.cc
+++ b/chrome_frame/test/policy_settings_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/basictypes.h"
+#include "base/at_exit.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/stringprintf.h"
@@ -132,14 +133,34 @@ bool SetChromeApplicationLocale(HKEY policy_root, const wchar_t* locale) {
} // end namespace
-TEST(PolicySettings, RendererForUrl) {
- TempRegKeyOverride::DeleteAllTempKeys();
+class PolicySettingsTest : public testing::Test {
+ protected:
+ void SetUp() {
+ TempRegKeyOverride::DeleteAllTempKeys();
+
+ hklm_pol_.reset(new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_pol"));
+ hkcu_pol_.reset(new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_pol"));
+
+ ResetPolicySettings();
+ }
+
+ void TearDown() {
+ hkcu_pol_.reset(NULL);
+ hklm_pol_.reset(NULL);
+ TempRegKeyOverride::DeleteAllTempKeys();
+ }
+
+ void ResetPolicySettings() {
+ at_exit_manager_.ProcessCallbacksNow();
+ }
- scoped_ptr<TempRegKeyOverride> hklm_pol(
- new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_pol"));
- scoped_ptr<TempRegKeyOverride> hkcu_pol(
- new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_pol"));
+ // This is used to manage life cycle of PolicySettings singleton.
+ base::ShadowingAtExitManager at_exit_manager_;
+ scoped_ptr<TempRegKeyOverride> hklm_pol_;
+ scoped_ptr<TempRegKeyOverride> hkcu_pol_;
+};
+TEST_F(PolicySettingsTest, RendererForUrl) {
const wchar_t* kTestUrls[] = {
L"http://www.example.com",
L"http://www.pattern.com",
@@ -152,11 +173,10 @@ TEST(PolicySettings, RendererForUrl) {
};
const wchar_t kNoMatchUrl[] = L"http://www.chromium.org";
- scoped_ptr<PolicySettings> settings(new PolicySettings());
EXPECT_EQ(PolicySettings::RENDERER_NOT_SPECIFIED,
- settings->default_renderer());
+ PolicySettings::GetInstance()->default_renderer());
EXPECT_EQ(PolicySettings::RENDERER_NOT_SPECIFIED,
- settings->GetRendererForUrl(kNoMatchUrl));
+ PolicySettings::GetInstance()->GetRendererForUrl(kNoMatchUrl));
HKEY root[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
for (int i = 0; i < arraysize(root); ++i) {
@@ -164,44 +184,33 @@ TEST(PolicySettings, RendererForUrl) {
PolicySettings::RENDER_IN_CHROME_FRAME, kTestFilters,
arraysize(kTestFilters)));
- settings.reset(new PolicySettings());
+ ResetPolicySettings();
EXPECT_EQ(PolicySettings::RENDER_IN_CHROME_FRAME,
- settings->GetRendererForUrl(kNoMatchUrl));
+ PolicySettings::GetInstance()->GetRendererForUrl(kNoMatchUrl));
for (int j = 0; j < arraysize(kTestUrls); ++j) {
EXPECT_EQ(PolicySettings::RENDER_IN_HOST,
- settings->GetRendererForUrl(kTestUrls[j]));
+ PolicySettings::GetInstance()->GetRendererForUrl(kTestUrls[j]));
}
EXPECT_TRUE(SetRendererSettings(root[i],
PolicySettings::RENDER_IN_HOST, NULL, 0));
- settings.reset(new PolicySettings());
+ ResetPolicySettings();
EXPECT_EQ(PolicySettings::RENDER_IN_HOST,
- settings->GetRendererForUrl(kNoMatchUrl));
+ PolicySettings::GetInstance()->GetRendererForUrl(kNoMatchUrl));
for (int j = 0; j < arraysize(kTestUrls); ++j) {
EXPECT_EQ(PolicySettings::RENDER_IN_HOST,
- settings->GetRendererForUrl(kTestUrls[j]));
+ PolicySettings::GetInstance()->GetRendererForUrl(kTestUrls[j]));
}
DeleteChromeFramePolicyEntries(root[i]);
}
-
- hkcu_pol.reset(NULL);
- hklm_pol.reset(NULL);
- TempRegKeyOverride::DeleteAllTempKeys();
}
-TEST(PolicySettings, RendererForContentType) {
- TempRegKeyOverride::DeleteAllTempKeys();
-
- scoped_ptr<TempRegKeyOverride> hklm_pol(
- new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_pol"));
- scoped_ptr<TempRegKeyOverride> hkcu_pol(
- new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_pol"));
-
- scoped_ptr<PolicySettings> settings(new PolicySettings());
+TEST_F(PolicySettingsTest, RendererForContentType) {
EXPECT_EQ(PolicySettings::RENDERER_NOT_SPECIFIED,
- settings->GetRendererForContentType(L"text/xml"));
+ PolicySettings::GetInstance()->GetRendererForContentType(
+ L"text/xml"));
const wchar_t* kTestPolicyContentTypes[] = {
L"application/xml",
@@ -213,39 +222,32 @@ TEST(PolicySettings, RendererForContentType) {
for (int i = 0; i < arraysize(root); ++i) {
SetCFContentTypes(root[i], kTestPolicyContentTypes,
arraysize(kTestPolicyContentTypes));
- settings.reset(new PolicySettings());
+ ResetPolicySettings();
for (int type = 0; type < arraysize(kTestPolicyContentTypes); ++type) {
EXPECT_EQ(PolicySettings::RENDER_IN_CHROME_FRAME,
- settings->GetRendererForContentType(
+ PolicySettings::GetInstance()->GetRendererForContentType(
kTestPolicyContentTypes[type]));
}
EXPECT_EQ(PolicySettings::RENDERER_NOT_SPECIFIED,
- settings->GetRendererForContentType(L"text/html"));
+ PolicySettings::GetInstance()->GetRendererForContentType(
+ L"text/html"));
DeleteChromeFramePolicyEntries(root[i]);
}
}
-TEST(PolicySettings, ApplicationLocale) {
- TempRegKeyOverride::DeleteAllTempKeys();
-
- scoped_ptr<TempRegKeyOverride> hklm_pol(
- new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_pol"));
- scoped_ptr<TempRegKeyOverride> hkcu_pol(
- new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_pol"));
-
- scoped_ptr<PolicySettings> settings(new PolicySettings());
- EXPECT_TRUE(settings->ApplicationLocale().empty());
+TEST_F(PolicySettingsTest, ApplicationLocale) {
+ EXPECT_TRUE(PolicySettings::GetInstance()->ApplicationLocale().empty());
static const wchar_t kTestApplicationLocale[] = L"fr-CA";
HKEY root[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
for (int i = 0; i < arraysize(root); ++i) {
SetChromeApplicationLocale(root[i], kTestApplicationLocale);
- settings.reset(new PolicySettings());
+ ResetPolicySettings();
EXPECT_EQ(std::wstring(kTestApplicationLocale),
- settings->ApplicationLocale());
+ PolicySettings::GetInstance()->ApplicationLocale());
DeleteChromeFramePolicyEntries(root[i]);
}
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index e4279a7..781d6d4 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -723,8 +723,8 @@ bool IsGcfDefaultRenderer() {
DWORD is_default = 0; // NOLINT
// First check policy settings
- Singleton<PolicySettings> policy;
- PolicySettings::RendererForUrl renderer = policy->default_renderer();
+ PolicySettings::RendererForUrl renderer =
+ PolicySettings::GetInstance()->default_renderer();
if (renderer != PolicySettings::RENDERER_NOT_SPECIFIED) {
is_default = (renderer == PolicySettings::RENDER_IN_CHROME_FRAME);
} else {
@@ -742,9 +742,8 @@ bool IsGcfDefaultRenderer() {
RendererType RendererTypeForUrl(const std::wstring& url) {
// First check if the default renderer settings are specified by policy.
// If so, then that overrides the user settings.
- Singleton<PolicySettings> policy;
- PolicySettings::RendererForUrl renderer = policy->GetRendererForUrl(
- url.c_str());
+ PolicySettings::RendererForUrl renderer =
+ PolicySettings::GetInstance()->GetRendererForUrl(url.c_str());
if (renderer != PolicySettings::RENDERER_NOT_SPECIFIED) {
// We may know at this point that policy says do NOT render in Chrome Frame.
// To maintain consistency, we return RENDERER_TYPE_UNDETERMINED so that
diff --git a/gfx/gtk_native_view_id_manager.cc b/gfx/gtk_native_view_id_manager.cc
index 8d9334d..904f46b 100644
--- a/gfx/gtk_native_view_id_manager.cc
+++ b/gfx/gtk_native_view_id_manager.cc
@@ -41,6 +41,11 @@ GtkNativeViewManager::GtkNativeViewManager() {
GtkNativeViewManager::~GtkNativeViewManager() {
}
+// static
+GtkNativeViewManager* GtkNativeViewManager::GetInstance() {
+ return Singleton<GtkNativeViewManager>::get();
+}
+
gfx::NativeViewId GtkNativeViewManager::GetIdForWidget(gfx::NativeView widget) {
// This is just for unit tests:
if (!widget)
diff --git a/gfx/gtk_native_view_id_manager.h b/gfx/gtk_native_view_id_manager.h
index 05cf0d7..e97a852 100644
--- a/gfx/gtk_native_view_id_manager.h
+++ b/gfx/gtk_native_view_id_manager.h
@@ -36,11 +36,11 @@ struct _GtkPreserveWindow;
// pointers and observes the various signals from the widget for when an X
// window is created, destroyed etc. Thus it provides a thread safe mapping
// from NativeViewIds to the current XID for that widget.
-//
-// You get a reference to the global instance with:
-// Singleton<GtkNativeViewManager>()
class GtkNativeViewManager {
public:
+ // Returns the singleton instance.
+ static GtkNativeViewManager* GetInstance();
+
// Must be called from the UI thread:
//
// Return a NativeViewId for the given widget and attach to the various
diff --git a/gfx/native_widget_types_gtk.cc b/gfx/native_widget_types_gtk.cc
index 097af2b..ccf428c 100644
--- a/gfx/native_widget_types_gtk.cc
+++ b/gfx/native_widget_types_gtk.cc
@@ -9,7 +9,7 @@
namespace gfx {
NativeViewId IdFromNativeView(NativeView view) {
- return Singleton<GtkNativeViewManager>()->GetIdForWidget(view);
+ return GtkNativeViewManager::GetInstance()->GetIdForWidget(view);
}
} // namespace gfx
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 1ab307e..3024050 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -391,7 +391,7 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
data_source_ = data_source;
// Add ourself to Protocol list and get our unique key.
- std::string key = FFmpegGlue::get()->AddProtocol(this);
+ std::string key = FFmpegGlue::GetInstance()->AddProtocol(this);
// Open FFmpeg AVFormatContext.
DCHECK(!format_context_);
@@ -399,7 +399,7 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
int result = av_open_input_file(&context, key.c_str(), NULL, 0, NULL);
// Remove ourself from protocol list.
- FFmpegGlue::get()->RemoveProtocol(this);
+ FFmpegGlue::GetInstance()->RemoveProtocol(this);
if (result < 0) {
host()->SetError(DEMUXER_ERROR_COULD_NOT_OPEN);
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index 6f637c3..663fff7 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -16,7 +16,7 @@ media::FFmpegURLProtocol* ToProtocol(void* data) {
// FFmpeg protocol interface.
int OpenContext(URLContext* h, const char* filename, int flags) {
media::FFmpegURLProtocol* protocol;
- media::FFmpegGlue::get()->GetProtocol(filename, &protocol);
+ media::FFmpegGlue::GetInstance()->GetProtocol(filename, &protocol);
if (!protocol)
return AVERROR_IO;
@@ -145,6 +145,11 @@ FFmpegGlue::~FFmpegGlue() {
av_lockmgr_register(NULL);
}
+// static
+FFmpegGlue* FFmpegGlue::GetInstance() {
+ return Singleton<FFmpegGlue>::get();
+}
+
std::string FFmpegGlue::AddProtocol(FFmpegURLProtocol* protocol) {
AutoLock auto_lock(lock_);
std::string key = GetProtocolKey(protocol);
diff --git a/media/filters/ffmpeg_glue.h b/media/filters/ffmpeg_glue.h
index 1ae4ded..4f991d1 100644
--- a/media/filters/ffmpeg_glue.h
+++ b/media/filters/ffmpeg_glue.h
@@ -64,8 +64,11 @@ class FFmpegURLProtocol {
DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol);
};
-class FFmpegGlue : public Singleton<FFmpegGlue> {
+class FFmpegGlue {
public:
+ // Returns the singleton instance.
+ static FFmpegGlue* GetInstance();
+
// Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string
// that can be passed to FFmpeg to identify the data source.
std::string AddProtocol(FFmpegURLProtocol* protocol);
diff --git a/media/filters/ffmpeg_glue_unittest.cc b/media/filters/ffmpeg_glue_unittest.cc
index d217f9c..f823669 100644
--- a/media/filters/ffmpeg_glue_unittest.cc
+++ b/media/filters/ffmpeg_glue_unittest.cc
@@ -43,7 +43,7 @@ class FFmpegGlueTest : public ::testing::Test {
MockFFmpeg::set(&mock_ffmpeg_);
// Singleton should initialize FFmpeg.
- CHECK(FFmpegGlue::get());
+ CHECK(FFmpegGlue::GetInstance());
// Assign our static copy of URLProtocol for the rest of the tests.
protocol_ = MockFFmpeg::protocol();
@@ -61,10 +61,10 @@ class FFmpegGlueTest : public ::testing::Test {
EXPECT_CALL(*protocol, IsStreaming()).WillOnce(Return(true));
// Add the protocol to the glue layer and open a context.
- std::string key = FFmpegGlue::get()->AddProtocol(protocol);
+ std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol);
memset(context, 0, sizeof(*context));
EXPECT_EQ(0, protocol_->url_open(context, key.c_str(), 0));
- FFmpegGlue::get()->RemoveProtocol(protocol);
+ FFmpegGlue::GetInstance()->RemoveProtocol(protocol);
}
protected:
@@ -90,7 +90,7 @@ TEST_F(FFmpegGlueTest, InitializeFFmpeg) {
TEST_F(FFmpegGlueTest, AddRemoveGetProtocol) {
// Prepare testing data.
- FFmpegGlue* glue = FFmpegGlue::get();
+ FFmpegGlue* glue = FFmpegGlue::GetInstance();
// Create our protocols and add them to the glue layer.
scoped_ptr<StrictMock<Destroyable<MockProtocol> > > protocol_a(
@@ -144,7 +144,7 @@ TEST_F(FFmpegGlueTest, AddRemoveGetProtocol) {
TEST_F(FFmpegGlueTest, OpenClose) {
// Prepare testing data.
- FFmpegGlue* glue = FFmpegGlue::get();
+ FFmpegGlue* glue = FFmpegGlue::GetInstance();
// Create our protocol and add them to the glue layer.
scoped_ptr<StrictMock<Destroyable<MockProtocol> > > protocol(
@@ -311,7 +311,7 @@ TEST_F(FFmpegGlueTest, Destroy) {
// Create our protocol and add them to the glue layer.
scoped_ptr<StrictMock<Destroyable<MockProtocol> > > protocol(
new StrictMock<Destroyable<MockProtocol> >());
- std::string key = FFmpegGlue::get()->AddProtocol(protocol.get());
+ std::string key = FFmpegGlue::GetInstance()->AddProtocol(protocol.get());
// We should expect the protocol to get destroyed when the unit test
// exits.
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index 2007ff1..4848e4b 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -80,6 +80,11 @@ FocusManager::~FocusManager() {
DCHECK(focus_change_listeners_.empty());
}
+// static
+FocusManager::WidgetFocusManager* FocusManager::GetWidgetFocusManager() {
+ return Singleton<WidgetFocusManager>::get();
+}
+
bool FocusManager::OnKeyEvent(const KeyEvent& event) {
#if defined(OS_WIN)
// If the focused view wants to process the key event as is, let it be.
diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h
index af6f414..28f97b4 100644
--- a/views/focus/focus_manager.h
+++ b/views/focus/focus_manager.h
@@ -176,9 +176,7 @@ class FocusManager {
virtual ~FocusManager();
// Returns the global WidgetFocusManager instance for the running application.
- static WidgetFocusManager* GetWidgetFocusManager() {
- return Singleton<WidgetFocusManager>::get();
- }
+ static WidgetFocusManager* GetWidgetFocusManager();
// Processes the passed key event for accelerators and tab traversal.
// Returns false if the event has been consumed and should not be processed
diff --git a/webkit/glue/plugins/pepper_resource_tracker.cc b/webkit/glue/plugins/pepper_resource_tracker.cc
index ba6f8f0..f9d24ed 100644
--- a/webkit/glue/plugins/pepper_resource_tracker.cc
+++ b/webkit/glue/plugins/pepper_resource_tracker.cc
@@ -29,6 +29,11 @@ ResourceTracker::ResourceTracker()
ResourceTracker::~ResourceTracker() {
}
+// static
+ResourceTracker* ResourceTracker::Get() {
+ return Singleton<ResourceTracker>::get();
+}
+
PP_Resource ResourceTracker::AddResource(Resource* resource) {
// If the plugin manages to create 4B resources...
if (last_id_ == std::numeric_limits<PP_Resource>::max()) {
diff --git a/webkit/glue/plugins/pepper_resource_tracker.h b/webkit/glue/plugins/pepper_resource_tracker.h
index ad25d1a..8e294855 100644
--- a/webkit/glue/plugins/pepper_resource_tracker.h
+++ b/webkit/glue/plugins/pepper_resource_tracker.h
@@ -29,9 +29,7 @@ class Resource;
class ResourceTracker {
public:
// Returns the pointer to the singleton object.
- static ResourceTracker* Get() {
- return Singleton<ResourceTracker>::get();
- }
+ static ResourceTracker* Get();
// PP_Resources --------------------------------------------------------------