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

Side by Side Diff: webkit/blob/deletable_file_reference.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/surface/accelerated_surface_win.cc ('k') | webkit/glue/webkit_glue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/blob/deletable_file_reference.h" 5 #include "webkit/blob/deletable_file_reference.h"
6 6
7 #include <map> 7 #include <map>
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/file_util_proxy.h" 9 #include "base/file_util_proxy.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 12
13 namespace webkit_blob { 13 namespace webkit_blob {
14 14
15 namespace { 15 namespace {
16 16
17 typedef std::map<FilePath, DeletableFileReference*> DeleteableFileMap; 17 typedef std::map<FilePath, DeletableFileReference*> DeleteableFileMap;
18 static base::LazyInstance<DeleteableFileMap> g_deletable_file_map( 18 static base::LazyInstance<DeleteableFileMap> g_deletable_file_map =
19 base::LINKER_INITIALIZED); 19 LAZY_INSTANCE_INITIALIZER;
20 20
21 } // namespace 21 } // namespace
22 22
23 // static 23 // static
24 scoped_refptr<DeletableFileReference> DeletableFileReference::Get( 24 scoped_refptr<DeletableFileReference> DeletableFileReference::Get(
25 const FilePath& path) { 25 const FilePath& path) {
26 DeleteableFileMap::iterator found = g_deletable_file_map.Get().find(path); 26 DeleteableFileMap::iterator found = g_deletable_file_map.Get().find(path);
27 DeletableFileReference* reference = 27 DeletableFileReference* reference =
28 (found == g_deletable_file_map.Get().end()) ? NULL : found->second; 28 (found == g_deletable_file_map.Get().end()) ? NULL : found->second;
29 return scoped_refptr<DeletableFileReference>(reference); 29 return scoped_refptr<DeletableFileReference>(reference);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 for (size_t i = 0; i < deletion_callbacks_.size(); i++) 70 for (size_t i = 0; i < deletion_callbacks_.size(); i++)
71 deletion_callbacks_[i].Run(path_); 71 deletion_callbacks_[i].Run(path_);
72 72
73 DCHECK(g_deletable_file_map.Get().find(path_)->second == this); 73 DCHECK(g_deletable_file_map.Get().find(path_)->second == this);
74 g_deletable_file_map.Get().erase(path_); 74 g_deletable_file_map.Get().erase(path_);
75 base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */, 75 base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */,
76 base::FileUtilProxy::StatusCallback()); 76 base::FileUtilProxy::StatusCallback());
77 } 77 }
78 78
79 } // namespace webkit_blob 79 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « ui/gfx/surface/accelerated_surface_win.cc ('k') | webkit/glue/webkit_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698