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 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
8 #include "base/file_util.h" | 11 #include "base/file_util.h" |
9 #include "base/file_util_proxy.h" | |
10 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/location.h" |
11 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
12 | 15 |
13 namespace webkit_blob { | 16 namespace webkit_blob { |
14 | 17 |
15 namespace { | 18 namespace { |
16 | 19 |
17 typedef std::map<FilePath, DeletableFileReference*> DeleteableFileMap; | 20 typedef std::map<FilePath, DeletableFileReference*> DeleteableFileMap; |
18 static base::LazyInstance<DeleteableFileMap> g_deletable_file_map( | 21 static base::LazyInstance<DeleteableFileMap> g_deletable_file_map( |
19 base::LINKER_INITIALIZED); | 22 base::LINKER_INITIALIZED); |
20 | 23 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 : path_(path), file_thread_(file_thread) { | 68 : path_(path), file_thread_(file_thread) { |
66 DCHECK(g_deletable_file_map.Get().find(path_)->second == NULL); | 69 DCHECK(g_deletable_file_map.Get().find(path_)->second == NULL); |
67 } | 70 } |
68 | 71 |
69 DeletableFileReference::~DeletableFileReference() { | 72 DeletableFileReference::~DeletableFileReference() { |
70 for (size_t i = 0; i < deletion_callbacks_.size(); i++) | 73 for (size_t i = 0; i < deletion_callbacks_.size(); i++) |
71 deletion_callbacks_[i].Run(path_); | 74 deletion_callbacks_[i].Run(path_); |
72 | 75 |
73 DCHECK(g_deletable_file_map.Get().find(path_)->second == this); | 76 DCHECK(g_deletable_file_map.Get().find(path_)->second == this); |
74 g_deletable_file_map.Get().erase(path_); | 77 g_deletable_file_map.Get().erase(path_); |
75 base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */, NULL); | 78 file_thread_->PostTask( |
| 79 FROM_HERE, |
| 80 base::IgnoreReturn(base::Callback<bool(void)>( |
| 81 base::Bind(&file_util::Delete, path_, false /* recursive */)))); |
76 } | 82 } |
77 | 83 |
78 } // namespace webkit_blob | 84 } // namespace webkit_blob |
OLD | NEW |