summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-11 10:23:37 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-11 10:23:37 +0000
commit5820d2f0458c851b18df616ef3aff80cb4f8dba4 (patch)
treedda803c05296f1bd8ee622c6d708a494373dcd1a /chrome
parent9acd869ec5621373757a6959310f39e1f5ec3f3d (diff)
downloadchromium_src-5820d2f0458c851b18df616ef3aff80cb4f8dba4.zip
chromium_src-5820d2f0458c851b18df616ef3aff80cb4f8dba4.tar.gz
chromium_src-5820d2f0458c851b18df616ef3aff80cb4f8dba4.tar.bz2
Revert 68932 - Make members of Singleton<T> private and only visible to the singleton type. This enforces that the Singleton<T> pattern can only be used within classes which want singleton-ness.
As part of this CL I have also fixed up files which got missed in my previous CLs to use a GetInstance() method and use Singleton<T> from the source file. There are a small number of places where I have also switched to LazyInstance as that was more appropriate for types used in a single source file. BUG=65298 TEST=all existing tests should continue to pass. Review URL: http://codereview.chromium.org/5682008 TBR=satish@chromium.org Review URL: http://codereview.chromium.org/5721005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/browser_main_chromeos.cc9
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc7
-rw-r--r--chrome/browser/chromeos/login/signed_settings_helper.cc9
-rw-r--r--chrome/browser/chromeos/offline/offline_load_service.cc9
-rw-r--r--chrome/browser/enumerate_modules_model_win.cc5
-rw-r--r--chrome/browser/enumerate_modules_model_win.h4
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc5
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.h6
-rw-r--r--chrome/common/sqlite_utils.cc7
-rw-r--r--chrome/common/time_format.cc12
-rw-r--r--chrome/plugin/webplugin_proxy.cc12
-rw-r--r--chrome/renderer/extensions/bindings_utils.cc10
-rw-r--r--chrome/renderer/extensions/renderer_extension_bindings.cc13
-rw-r--r--chrome/renderer/ggl/ggl.cc8
-rw-r--r--chrome/renderer/render_view.cc13
16 files changed, 51 insertions, 80 deletions
diff --git a/chrome/browser/chromeos/browser_main_chromeos.cc b/chrome/browser/chromeos/browser_main_chromeos.cc
index 776a82b..df4653a 100644
--- a/chrome/browser/chromeos/browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/browser_main_chromeos.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/chromeos/browser_main_chromeos.h"
-#include "base/lazy_instance.h"
#include "base/message_loop.h"
+#include "base/singleton.h"
#include <gtk/gtk.h>
@@ -38,13 +38,12 @@ class MessageLoopObserver : public MessageLoopForUI::Observer {
}
};
-static base::LazyInstance<MessageLoopObserver> g_message_loop_observer(
- base::LINKER_INITIALIZED);
-
void BrowserMainPartsChromeos::PostMainMessageLoopStart() {
+ static Singleton<MessageLoopObserver> observer;
+
BrowserMainPartsPosix::PostMainMessageLoopStart();
MessageLoopForUI* message_loop = MessageLoopForUI::current();
- message_loop->AddObserver(g_message_loop_observer.Pointer());
+ message_loop->AddObserver(observer.get());
}
// static
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 2167650..f59307b 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -16,9 +16,9 @@
#include "app/resource_bundle.h"
#include "app/x11_util.h"
#include "base/command_line.h"
-#include "base/lazy_instance.h"
#include "base/metrics/histogram.h"
#include "base/message_loop.h"
+#include "base/singleton.h"
#include "base/string_util.h"
#include "base/timer.h"
#include "base/utf_string_conversions.h"
@@ -194,9 +194,6 @@ class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver);
};
-static base::LazyInstance<ScreenLockObserver> g_screen_lock_observer(
- base::LINKER_INITIALIZED);
-
// A ScreenLock window that covers entire screen to keep the keyboard
// focus/events inside the grab widget.
class LockWindow : public views::WidgetGtk {
@@ -904,7 +901,7 @@ void ScreenLocker::UnlockScreenFailed() {
// static
void ScreenLocker::InitClass() {
- g_screen_lock_observer.Get();
+ Singleton<ScreenLockObserver>::get();
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/login/signed_settings_helper.cc b/chrome/browser/chromeos/login/signed_settings_helper.cc
index 6a1a735..ad86e83 100644
--- a/chrome/browser/chromeos/login/signed_settings_helper.cc
+++ b/chrome/browser/chromeos/login/signed_settings_helper.cc
@@ -7,9 +7,9 @@
#include <string>
#include <vector>
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/ref_counted.h"
+#include "base/singleton.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/chromeos/login/signed_settings.h"
@@ -262,13 +262,10 @@ class SignedSettingsHelperImpl : public SignedSettingsHelper,
std::vector<OpContext*> pending_contexts_;
- friend struct base::DefaultLazyInstanceTraits<SignedSettingsHelperImpl>;
+ friend struct DefaultSingletonTraits<SignedSettingsHelperImpl>;
DISALLOW_COPY_AND_ASSIGN(SignedSettingsHelperImpl);
};
-static base::LazyInstance<SignedSettingsHelperImpl>
- g_signed_settings_helper_impl(base::LINKER_INITIALIZED);
-
SignedSettingsHelperImpl::SignedSettingsHelperImpl() {
}
@@ -374,7 +371,7 @@ void SignedSettingsHelperImpl::OnOpCompleted(OpContext* context) {
}
SignedSettingsHelper* SignedSettingsHelper::Get() {
- return g_signed_settings_helper_impl.Pointer();
+ return Singleton<SignedSettingsHelperImpl>::get();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/offline/offline_load_service.cc b/chrome/browser/chromeos/offline/offline_load_service.cc
index ace85d8..08f2362 100644
--- a/chrome/browser/chromeos/offline/offline_load_service.cc
+++ b/chrome/browser/chromeos/offline/offline_load_service.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/chromeos/offline/offline_load_service.h"
-#include "base/lazy_instance.h"
#include "base/ref_counted.h"
+#include "base/singleton.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -24,7 +24,7 @@ class OfflineLoadServiceSingleton {
}
private:
- friend struct base::DefaultLazyInstanceTraits<OfflineLoadServiceSingleton>;
+ friend struct DefaultSingletonTraits<OfflineLoadServiceSingleton>;
OfflineLoadServiceSingleton()
: offline_load_service_(new chromeos::OfflineLoadService()) {}
virtual ~OfflineLoadServiceSingleton() {}
@@ -34,12 +34,9 @@ class OfflineLoadServiceSingleton {
DISALLOW_COPY_AND_ASSIGN(OfflineLoadServiceSingleton);
};
-static base::LazyInstance<OfflineLoadServiceSingleton>
- g_offline_load_service_singleton(base::LINKER_INITIALIZED);
-
// static
OfflineLoadService* OfflineLoadService::Get() {
- return g_offline_load_service_singleton.Get().offline_load_service();
+ return Singleton<OfflineLoadServiceSingleton>::get()->offline_load_service();
}
void OfflineLoadService::Observe(NotificationType type,
diff --git a/chrome/browser/enumerate_modules_model_win.cc b/chrome/browser/enumerate_modules_model_win.cc
index cff39c6..b521b6c 100644
--- a/chrome/browser/enumerate_modules_model_win.cc
+++ b/chrome/browser/enumerate_modules_model_win.cc
@@ -672,11 +672,6 @@ string16 ModuleEnumerator::GetSubjectNameFromDigitalSignature(
// ----------------------------------------------------------------------------
-// static
-EnumerateModulesModel* EnumerateModulesModel::GetSingleton() {
- return Singleton<EnumerateModulesModel>::get();
-}
-
void EnumerateModulesModel::ScanNow() {
if (scanning_)
return; // A scan is already in progress.
diff --git a/chrome/browser/enumerate_modules_model_win.h b/chrome/browser/enumerate_modules_model_win.h
index 15492a5..9000a6c 100644
--- a/chrome/browser/enumerate_modules_model_win.h
+++ b/chrome/browser/enumerate_modules_model_win.h
@@ -218,7 +218,9 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
// notification.
class EnumerateModulesModel {
public:
- static EnumerateModulesModel* GetSingleton();
+ static EnumerateModulesModel* GetSingleton() {
+ return Singleton<EnumerateModulesModel>::get();
+ }
// Returns the number of suspected bad modules found in the last scan.
// Returns 0 if no scan has taken place yet.
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index d3dffff..ad10e51 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -626,7 +626,7 @@ bool BrowserToolbarGtk::ShouldOnlyShowLocation() const {
gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender,
GdkEventExpose* expose) {
- if (!UpgradeDetector::GetInstance()->notify_upgrade())
+ if (!Singleton<UpgradeDetector>::get()->notify_upgrade())
return FALSE;
const SkBitmap& badge =
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 2bc0a49..7ec0303 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -76,9 +76,6 @@ static const char* const kTakeMeBackCommand = "takeMeBack";
// static
SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
-static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
- g_unsafe_resource_map(base::LINKER_INITIALIZED);
-
// The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we
// don't leak it.
class SafeBrowsingBlockingPageFactoryImpl
@@ -562,7 +559,7 @@ void SafeBrowsingBlockingPage::NotifySafeBrowsingService(
// static
SafeBrowsingBlockingPage::UnsafeResourceMap*
SafeBrowsingBlockingPage::GetUnsafeResourcesMap() {
- return g_unsafe_resource_map.Pointer();
+ return Singleton<UnsafeResourceMap>::get();
}
// static
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
index cfe2358..53b21a0 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
@@ -44,9 +44,6 @@ class TabContents;
class SafeBrowsingBlockingPage : public InterstitialPage {
public:
- typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList;
- typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap;
-
virtual ~SafeBrowsingBlockingPage();
// Shows a blocking page warning the user about phishing/malware for a
@@ -69,6 +66,8 @@ class SafeBrowsingBlockingPage : public InterstitialPage {
virtual void Proceed();
virtual void DontProceed();
+ typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList;
+
protected:
friend class SafeBrowsingBlockingPageTest;
@@ -119,6 +118,7 @@ class SafeBrowsingBlockingPage : public InterstitialPage {
// A list of SafeBrowsingService::UnsafeResource for a tab that the user
// should be warned about. They are queued when displaying more than one
// interstitial at a time.
+ typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap;
static UnsafeResourceMap* GetUnsafeResourcesMap();
// Notifies the SafeBrowsingService on the IO thread whether to proceed or not
diff --git a/chrome/common/sqlite_utils.cc b/chrome/common/sqlite_utils.cc
index 9d16c7f..d11b925 100644
--- a/chrome/common/sqlite_utils.cc
+++ b/chrome/common/sqlite_utils.cc
@@ -8,8 +8,8 @@
#include "base/file_path.h"
#include "base/lock.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/singleton.h"
#include "base/stl_util-inl.h"
#include "base/string16.h"
@@ -76,13 +76,10 @@ class DefaultSQLErrorHandlerFactory : public SQLErrorHandlerFactory {
Lock lock_;
};
-static base::LazyInstance<DefaultSQLErrorHandlerFactory>
- g_default_sql_error_handler_factory(base::LINKER_INITIALIZED);
-
SQLErrorHandlerFactory* GetErrorHandlerFactory() {
// TODO(cpu): Testing needs to override the error handler.
// Destruction of DefaultSQLErrorHandlerFactory handled by at_exit manager.
- return g_default_sql_error_handler_factory.Pointer();
+ return Singleton<DefaultSQLErrorHandlerFactory>::get();
}
namespace sqlite_utils {
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc
index 9de3a402..c62f4f5 100644
--- a/chrome/common/time_format.cc
+++ b/chrome/common/time_format.cc
@@ -7,9 +7,9 @@
#include <vector>
#include "app/l10n_util.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
+#include "base/singleton.h"
#include "base/stl_util-inl.h"
#include "base/string16.h"
#include "base/time.h"
@@ -168,7 +168,8 @@ class TimeFormatter {
STLDeleteContainerPointers(time_elapsed_formatter_.begin(),
time_elapsed_formatter_.end());
}
- friend struct base::DefaultLazyInstanceTraits<TimeFormatter>;
+ friend class Singleton<TimeFormatter>;
+ friend struct DefaultSingletonTraits<TimeFormatter>;
std::vector<icu::PluralFormat*> short_formatter_;
std::vector<icu::PluralFormat*> time_left_formatter_;
@@ -181,9 +182,6 @@ class TimeFormatter {
DISALLOW_COPY_AND_ASSIGN(TimeFormatter);
};
-static base::LazyInstance<TimeFormatter> g_time_formatter(
- base::LINKER_INITIALIZED);
-
void TimeFormatter::BuildFormats(
FormatType format_type, std::vector<icu::PluralFormat*>* time_formats) {
static const icu::UnicodeString kKeywords[] = {
@@ -255,6 +253,8 @@ icu::PluralFormat* TimeFormatter::createFallbackFormat(
return format;
}
+Singleton<TimeFormatter> time_formatter;
+
static string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) {
if (delta.ToInternalValue() < 0) {
NOTREACHED() << "Negative duration";
@@ -264,7 +264,7 @@ static string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) {
int number;
const std::vector<icu::PluralFormat*>& formatters =
- g_time_formatter.Get().formatter(format_type);
+ time_formatter->formatter(format_type);
UErrorCode error = U_ZERO_ERROR;
icu::UnicodeString time_string;
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index bb77108..87a4772 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -9,13 +9,13 @@
#if defined(OS_WIN)
#include "app/win_util.h"
#endif
-#include "base/lazy_instance.h"
#if defined(OS_MACOSX)
#include "base/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#endif
#include "base/scoped_handle.h"
#include "base/shared_memory.h"
+#include "base/singleton.h"
#include "build/build_config.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/plugin_messages.h"
@@ -47,7 +47,9 @@ using webkit_glue::WebPluginAcceleratedSurface;
#endif
typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap;
-static base::LazyInstance<ContextMap> g_context_map(base::LINKER_INITIALIZED);
+static ContextMap& GetContextMap() {
+ return *Singleton<ContextMap>::get();
+}
WebPluginProxy::WebPluginProxy(
PluginChannel* channel,
@@ -91,7 +93,7 @@ WebPluginProxy::WebPluginProxy(
WebPluginProxy::~WebPluginProxy() {
if (cp_browsing_context_)
- g_context_map.Get().erase(cp_browsing_context_);
+ GetContextMap().erase(cp_browsing_context_);
#if defined(USE_X11)
if (windowless_shm_pixmap_ != None)
@@ -269,14 +271,14 @@ CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() {
if (cp_browsing_context_ == 0) {
Send(new PluginHostMsg_GetCPBrowsingContext(route_id_,
&cp_browsing_context_));
- g_context_map.Get()[cp_browsing_context_] = this;
+ GetContextMap()[cp_browsing_context_] = this;
}
return cp_browsing_context_;
}
WebPluginProxy* WebPluginProxy::FromCPBrowsingContext(
CPBrowsingContext context) {
- return g_context_map.Get()[context];
+ return GetContextMap()[context];
}
WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) {
diff --git a/chrome/renderer/extensions/bindings_utils.cc b/chrome/renderer/extensions/bindings_utils.cc
index 4776966..5b213c4 100644
--- a/chrome/renderer/extensions/bindings_utils.cc
+++ b/chrome/renderer/extensions/bindings_utils.cc
@@ -4,7 +4,6 @@
#include "chrome/renderer/extensions/bindings_utils.h"
-#include "base/lazy_instance.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "chrome/renderer/render_view.h"
@@ -22,14 +21,11 @@ struct SingletonData {
ContextList contexts;
PendingRequestMap pending_requests;
};
-static base::LazyInstance<SingletonData> g_singleton_data(
- base::LINKER_INITIALIZED);
typedef std::map<int, std::string> StringMap;
-static base::LazyInstance<StringMap> g_string_map(base::LINKER_INITIALIZED);
const char* GetStringResource(int resource_id) {
- StringMap* strings = g_string_map.Pointer();
+ StringMap* strings = Singleton<StringMap>::get();
StringMap::iterator it = strings->find(resource_id);
if (it == strings->end()) {
it = strings->insert(std::make_pair(
@@ -88,7 +84,7 @@ ContextInfo::ContextInfo(v8::Persistent<v8::Context> context,
ContextInfo::~ContextInfo() {}
ContextList& GetContexts() {
- return g_singleton_data.Get().contexts;
+ return Singleton<SingletonData>::get()->contexts;
}
ContextList GetContextsForExtension(const std::string& extension_id) {
@@ -138,7 +134,7 @@ ContextList::iterator FindContext(v8::Handle<v8::Context> context) {
}
PendingRequestMap& GetPendingRequestMap() {
- return g_singleton_data.Get().pending_requests;
+ return Singleton<SingletonData>::get()->pending_requests;
}
RenderView* GetRenderViewForCurrentContext() {
diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc
index ab7a8eb..9555672 100644
--- a/chrome/renderer/extensions/renderer_extension_bindings.cc
+++ b/chrome/renderer/extensions/renderer_extension_bindings.cc
@@ -8,7 +8,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/lazy_instance.h"
+#include "base/singleton.h"
#include "base/values.h"
#include "chrome/common/extensions/extension_message_bundle.h"
#include "chrome/common/render_messages.h"
@@ -43,20 +43,17 @@ struct ExtensionData {
std::map<int, PortData> ports; // port ID -> data
};
-static base::LazyInstance<ExtensionData> g_extension_data(
- base::LINKER_INITIALIZED);
-
static bool HasPortData(int port_id) {
- return g_extension_data.Get().ports.find(port_id) !=
- g_extension_data.Get().ports.end();
+ return Singleton<ExtensionData>::get()->ports.find(port_id) !=
+ Singleton<ExtensionData>::get()->ports.end();
}
static ExtensionData::PortData& GetPortData(int port_id) {
- return g_extension_data.Get().ports[port_id];
+ return Singleton<ExtensionData>::get()->ports[port_id];
}
static void ClearPortData(int port_id) {
- g_extension_data.Get().ports.erase(port_id);
+ Singleton<ExtensionData>::get()->ports.erase(port_id);
}
const char kPortClosedError[] = "Attempting to use a disconnected port object";
diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc
index c95bbb5..577e853 100644
--- a/chrome/renderer/ggl/ggl.cc
+++ b/chrome/renderer/ggl/ggl.cc
@@ -4,8 +4,8 @@
#include "build/build_config.h"
-#include "base/lazy_instance.h"
#include "base/ref_counted.h"
+#include "base/singleton.h"
#include "base/weak_ptr.h"
#include "chrome/renderer/command_buffer_proxy.h"
#include "chrome/renderer/ggl/ggl.h"
@@ -48,10 +48,6 @@ class GLES2Initializer {
private:
DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
};
-
-static base::LazyInstance<GLES2Initializer> g_gles2_initializer(
- base::LINKER_INITIALIZED);
-
} // namespace anonymous
// Manages a GL context.
@@ -167,7 +163,7 @@ bool Context::Initialize(gfx::NativeViewId view,
return false;
// Ensure the gles2 library is initialized first in a thread safe way.
- g_gles2_initializer.Get();
+ Singleton<GLES2Initializer>::get();
// Allocate a frame buffer ID with respect to the parent.
if (parent_.get()) {
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index ca29c0a..e29e30a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -15,10 +15,10 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
-#include "base/lazy_instance.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/singleton.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
@@ -277,7 +277,6 @@ using webkit_glue::WebAccessibility;
//-----------------------------------------------------------------------------
typedef std::map<WebKit::WebView*, RenderView*> ViewMap;
-static base::LazyInstance<ViewMap> g_view_map(base::LINKER_INITIALIZED);
// define to write the time necessary for thumbnail/DOM text retrieval,
// respectively, into the system debug log
@@ -616,7 +615,7 @@ RenderView::~RenderView() {
#ifndef NDEBUG
// Make sure we are no longer referenced by the ViewMap.
- ViewMap* views = g_view_map.Pointer();
+ ViewMap* views = Singleton<ViewMap>::get();
for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
DCHECK_NE(this, it->second) << "Failed to call Close?";
#endif
@@ -624,7 +623,7 @@ RenderView::~RenderView() {
/*static*/
void RenderView::ForEach(RenderViewVisitor* visitor) {
- ViewMap* views = g_view_map.Pointer();
+ ViewMap* views = Singleton<ViewMap>::get();
for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) {
if (!visitor->Visit(it->second))
return;
@@ -633,7 +632,7 @@ void RenderView::ForEach(RenderViewVisitor* visitor) {
/*static*/
RenderView* RenderView::FromWebView(WebView* webview) {
- ViewMap* views = g_view_map.Pointer();
+ ViewMap* views = Singleton<ViewMap>::get();
ViewMap::iterator it = views->find(webview);
return it == views->end() ? NULL : it->second;
}
@@ -896,7 +895,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
devtools_agent_.reset(new DevToolsAgent(routing_id, this));
webwidget_ = WebView::create(this, devtools_agent_.get());
- g_view_map.Get().insert(std::make_pair(webview(), this));
+ Singleton<ViewMap>::get()->insert(std::make_pair(webview(), this));
webkit_preferences_.Apply(webview());
webview()->initializeMainFrame(this);
if (!frame_name.empty())
@@ -5448,7 +5447,7 @@ void RenderView::Close() {
// We need to grab a pointer to the doomed WebView before we destroy it.
WebView* doomed = webview();
RenderWidget::Close();
- g_view_map.Get().erase(doomed);
+ Singleton<ViewMap>::get()->erase(doomed);
}
void RenderView::DidHandleKeyEvent() {