From 5820d2f0458c851b18df616ef3aff80cb4f8dba4 Mon Sep 17 00:00:00 2001 From: "satish@chromium.org" Date: Sat, 11 Dec 2010 10:23:37 +0000 Subject: Revert 68932 - Make members of Singleton private and only visible to the singleton type. This enforces that the Singleton 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 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 --- webkit/blob/deletable_file_reference.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'webkit/blob') diff --git a/webkit/blob/deletable_file_reference.cc b/webkit/blob/deletable_file_reference.cc index 7a5cfac..87ef4cc 100644 --- a/webkit/blob/deletable_file_reference.cc +++ b/webkit/blob/deletable_file_reference.cc @@ -7,25 +7,27 @@ #include #include "base/file_util.h" #include "base/file_util_proxy.h" -#include "base/lazy_instance.h" #include "base/message_loop_proxy.h" +#include "base/singleton.h" namespace webkit_blob { namespace { typedef std::map DeleteableFileMap; -static base::LazyInstance g_deletable_file_map( - base::LINKER_INITIALIZED); + +DeleteableFileMap* map() { + return Singleton::get(); +} } // namespace // static scoped_refptr DeletableFileReference::Get( const FilePath& path) { - DeleteableFileMap::iterator found = g_deletable_file_map.Get().find(path); + DeleteableFileMap::iterator found = map()->find(path); DeletableFileReference* reference = - (found == g_deletable_file_map.Get().end()) ? NULL : found->second; + (found == map()->end()) ? NULL : found->second; return scoped_refptr(reference); } @@ -34,7 +36,7 @@ scoped_refptr DeletableFileReference::GetOrCreate( const FilePath& path, base::MessageLoopProxy* file_thread) { DCHECK(file_thread); typedef std::pair InsertResult; - InsertResult result = g_deletable_file_map.Get().insert( + InsertResult result = map()->insert( DeleteableFileMap::value_type(path, NULL)); if (result.second == false) return scoped_refptr(result.first->second); @@ -49,12 +51,12 @@ scoped_refptr DeletableFileReference::GetOrCreate( DeletableFileReference::DeletableFileReference( const FilePath& path, base::MessageLoopProxy* file_thread) : path_(path), file_thread_(file_thread) { - DCHECK(g_deletable_file_map.Get().find(path_)->second == NULL); + DCHECK(map()->find(path_)->second == NULL); } DeletableFileReference::~DeletableFileReference() { - DCHECK(g_deletable_file_map.Get().find(path_)->second == this); - g_deletable_file_map.Get().erase(path_); + DCHECK(map()->find(path_)->second == this); + map()->erase(path_); base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */, NULL); } -- cgit v1.1