Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm

Issue 5711001: Add a new GetInstance() method for remaining files with singleton classes under chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm
diff --git a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm
index 0f2271eab04fcf2026f1f16d0c9621fc83da693f..1a0819f88d638d0000f6f1180e64180d4e562f71 100644
--- a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm
@@ -7,7 +7,7 @@
#import "chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h"
#import "base/mac_util.h"
-#include "base/singleton.h"
+#include "base/lazy_instance.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -101,12 +101,15 @@ namespace {
typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap;
+static base::LazyInstance<ProfileControllerMap> g_profile_controller_map(
+ base::LINKER_INITIALIZED);
+
} // namespace
@implementation KeywordEditorCocoaController
+ (KeywordEditorCocoaController*)sharedInstanceForProfile:(Profile*)profile {
- ProfileControllerMap* map = Singleton<ProfileControllerMap>::get();
+ ProfileControllerMap* map = g_profile_controller_map.Pointer();
DCHECK(map != NULL);
ProfileControllerMap::iterator it = map->find(profile);
if (it != map->end()) {
@@ -125,7 +128,7 @@ typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap;
// either way, arrange to use the original profile instead.
profile = profile->GetOriginalProfile();
- ProfileControllerMap* map = Singleton<ProfileControllerMap>::get();
+ ProfileControllerMap* map = g_profile_controller_map.Pointer();
DCHECK(map != NULL);
ProfileControllerMap::iterator it = map->find(profile);
if (it == map->end()) {
@@ -194,7 +197,7 @@ typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap;
- (void)windowWillClose:(NSNotification*)notif {
[self autorelease];
- ProfileControllerMap* map = Singleton<ProfileControllerMap>::get();
+ ProfileControllerMap* map = g_profile_controller_map.Pointer();
ProfileControllerMap::iterator it = map->find(profile_);
// It should not be possible for this to be missing.
// TODO(shess): Except that the unit test reaches in directly.

Powered by Google App Engine
This is Rietveld 408576698