diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 10:43:08 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 10:43:08 +0000 |
commit | 687b96058845cdaa59f9d81c468f81222e60bdfd (patch) | |
tree | 9c97670a35e5f6abe40f3c4bf50ee7b5a257a0e3 /gfx | |
parent | d22618c155cd40c5740755a5f0bcaab59f13f9a7 (diff) | |
download | chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.zip chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.tar.gz chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.tar.bz2 |
Add a new GetInstance() method for singleton classes, take 2.
This is a small step towards making all singleton classes use the Singleton<T> pattern within their code and not expect the callers to know about it.
This CL includes all files except those under chrome/browser, chrome/net, chrome/service and third_party/WebKit (these will be done in future CLs).
Suggested files to focus for reviewers:
- joi@ for files under src/ceee
- tommi@ for files under src/chrome_frame
- maruel@ for the rest of the files.
BUG=65298
TEST=all existing tests should continue to pass.
Review URL: http://codereview.chromium.org/5581008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gtk_native_view_id_manager.cc | 5 | ||||
-rw-r--r-- | gfx/gtk_native_view_id_manager.h | 6 | ||||
-rw-r--r-- | gfx/native_widget_types_gtk.cc | 2 |
3 files changed, 9 insertions, 4 deletions
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 |