OLD | NEW |
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 Loading... |
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 |
OLD | NEW |