summaryrefslogtreecommitdiffstats
path: root/webkit/blob
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 /webkit/blob
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 'webkit/blob')
-rw-r--r--webkit/blob/deletable_file_reference.cc20
1 files changed, 11 insertions, 9 deletions
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 <map>
#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<FilePath, DeletableFileReference*> DeleteableFileMap;
-static base::LazyInstance<DeleteableFileMap> g_deletable_file_map(
- base::LINKER_INITIALIZED);
+
+DeleteableFileMap* map() {
+ return Singleton<DeleteableFileMap>::get();
+}
} // namespace
// static
scoped_refptr<DeletableFileReference> 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<DeletableFileReference>(reference);
}
@@ -34,7 +36,7 @@ scoped_refptr<DeletableFileReference> DeletableFileReference::GetOrCreate(
const FilePath& path, base::MessageLoopProxy* file_thread) {
DCHECK(file_thread);
typedef std::pair<DeleteableFileMap::iterator, bool> 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<DeletableFileReference>(result.first->second);
@@ -49,12 +51,12 @@ scoped_refptr<DeletableFileReference> 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);
}