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

Side by Side Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 12223075: Make SimpleEntryImpl::Doom() completely asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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
OLDNEW
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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 for (int i = 0; i < kSimpleEntryFileCount; ++i) { 104 for (int i = 0; i < kSimpleEntryFileCount; ++i) {
105 bool delete_result = 105 bool delete_result =
106 file_util::Delete(path.AppendASCII(GetFilenameForKeyAndIndex(key, i)), 106 file_util::Delete(path.AppendASCII(GetFilenameForKeyAndIndex(key, i)),
107 false); 107 false);
108 DCHECK(delete_result); 108 DCHECK(delete_result);
109 } 109 }
110 if (!callback.is_null()) 110 if (!callback.is_null())
111 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK)); 111 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK));
112 } 112 }
113 113
114 void SimpleSynchronousEntry::DoomAndClose() {
115 scoped_refptr<TaskRunner> callback_runner = callback_runner_;
116 FilePath path = path_;
117 std::string key = key_;
118
119 Close();
120 // |this| is now deleted.
121
122 DoomEntry(path, key, callback_runner, net::CompletionCallback());
123 }
124
125 void SimpleSynchronousEntry::Close() { 114 void SimpleSynchronousEntry::Close() {
126 for (int i = 0; i < kSimpleEntryFileCount; ++i) { 115 for (int i = 0; i < kSimpleEntryFileCount; ++i) {
127 bool result = ClosePlatformFile(files_[i]); 116 bool result = ClosePlatformFile(files_[i]);
128 DCHECK(result); 117 DCHECK(result);
129 } 118 }
130 delete this; 119 delete this;
131 } 120 }
132 121
133 void SimpleSynchronousEntry::ReadData( 122 void SimpleSynchronousEntry::ReadData(
134 int index, 123 int index,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 LOG(WARNING) << "Could not write keys to new cache entry."; 309 LOG(WARNING) << "Could not write keys to new cache entry.";
321 return false; 310 return false;
322 } 311 }
323 } 312 }
324 313
325 initialized_ = true; 314 initialized_ = true;
326 return true; 315 return true;
327 } 316 }
328 317
329 } // namespace disk_cache 318 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698