OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const net::CompletionCallback& callback) { | 105 const net::CompletionCallback& callback) { |
106 for (int i = 0; i < kSimpleEntryFileCount; ++i) { | 106 for (int i = 0; i < kSimpleEntryFileCount; ++i) { |
107 FilePath to_delete = path.AppendASCII(GetFilenameForKeyAndIndex(key, i)); | 107 FilePath to_delete = path.AppendASCII(GetFilenameForKeyAndIndex(key, i)); |
108 bool ALLOW_UNUSED result = file_util::Delete(to_delete, false); | 108 bool ALLOW_UNUSED result = file_util::Delete(to_delete, false); |
109 DLOG_IF(ERROR, !result) << "Could not delete " << to_delete.MaybeAsASCII(); | 109 DLOG_IF(ERROR, !result) << "Could not delete " << to_delete.MaybeAsASCII(); |
110 } | 110 } |
111 if (!callback.is_null()) | 111 if (!callback.is_null()) |
112 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK)); | 112 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK)); |
113 } | 113 } |
114 | 114 |
115 void SimpleSynchronousEntry::DoomAndClose() { | |
116 scoped_refptr<TaskRunner> callback_runner = callback_runner_; | |
117 FilePath path = path_; | |
118 std::string key = key_; | |
119 | |
120 Close(); | |
121 // |this| is now deleted. | |
122 | |
123 DoomEntry(path, key, callback_runner, net::CompletionCallback()); | |
124 } | |
125 | |
126 void SimpleSynchronousEntry::Close() { | 115 void SimpleSynchronousEntry::Close() { |
127 for (int i = 0; i < kSimpleEntryFileCount; ++i) { | 116 for (int i = 0; i < kSimpleEntryFileCount; ++i) { |
128 bool ALLOW_UNUSED result = ClosePlatformFile(files_[i]); | 117 bool ALLOW_UNUSED result = ClosePlatformFile(files_[i]); |
129 DLOG_IF(INFO, !result) << "Could not Close() file."; | 118 DLOG_IF(INFO, !result) << "Could not Close() file."; |
130 } | 119 } |
131 delete this; | 120 delete this; |
132 } | 121 } |
133 | 122 |
134 void SimpleSynchronousEntry::ReadData( | 123 void SimpleSynchronousEntry::ReadData( |
135 int index, | 124 int index, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 DLOG(WARNING) << "Could not write keys to new cache entry."; | 301 DLOG(WARNING) << "Could not write keys to new cache entry."; |
313 return false; | 302 return false; |
314 } | 303 } |
315 } | 304 } |
316 | 305 |
317 initialized_ = true; | 306 initialized_ = true; |
318 return true; | 307 return true; |
319 } | 308 } |
320 | 309 |
321 } // namespace disk_cache | 310 } // namespace disk_cache |
OLD | NEW |