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

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

Issue 22859060: Fix race condition for non-open/create operations happening after a doom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix parameters alignment Created 7 years, 3 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 #include <functional> 9 #include <functional>
10 #include <limits> 10 #include <limits>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 GetFilenameFromEntryHashAndIndex(entry_hash, i)); 239 GetFilenameFromEntryHashAndIndex(entry_hash, i));
240 if (!base::DeleteFile(to_delete, false)) { 240 if (!base::DeleteFile(to_delete, false)) {
241 result = false; 241 result = false;
242 DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII(); 242 DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII();
243 } 243 }
244 } 244 }
245 return result; 245 return result;
246 } 246 }
247 247
248 // static 248 // static
249 void SimpleSynchronousEntry::DoomEntry( 249 int SimpleSynchronousEntry::DoomEntry(
250 const FilePath& path, 250 const FilePath& path,
251 const std::string& key, 251 const std::string& key,
252 uint64 entry_hash, 252 uint64 entry_hash) {
253 int* out_result) {
254 DCHECK_EQ(entry_hash, GetEntryHashKey(key)); 253 DCHECK_EQ(entry_hash, GetEntryHashKey(key));
255 bool deleted_well = DeleteFilesForEntryHash(path, entry_hash); 254 const bool deleted_well = DeleteFilesForEntryHash(path, entry_hash);
256 *out_result = deleted_well ? net::OK : net::ERR_FAILED; 255 return deleted_well ? net::OK : net::ERR_FAILED;
257 } 256 }
258 257
259 // static 258 // static
260 int SimpleSynchronousEntry::DoomEntrySet( 259 int SimpleSynchronousEntry::DoomEntrySet(
261 scoped_ptr<std::vector<uint64> > key_hashes, 260 scoped_ptr<std::vector<uint64> > key_hashes,
262 const FilePath& path) { 261 const FilePath& path) {
263 const size_t did_delete_count = std::count_if( 262 const size_t did_delete_count = std::count_if(
264 key_hashes->begin(), key_hashes->end(), std::bind1st( 263 key_hashes->begin(), key_hashes->end(), std::bind1st(
265 std::ptr_fun(SimpleSynchronousEntry::DeleteFilesForEntryHash), path)); 264 std::ptr_fun(SimpleSynchronousEntry::DeleteFilesForEntryHash), path));
266 return (did_delete_count == key_hashes->size()) ? net::OK : net::ERR_FAILED; 265 return (did_delete_count == key_hashes->size()) ? net::OK : net::ERR_FAILED;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 initialized_ = true; 630 initialized_ = true;
632 return net::OK; 631 return net::OK;
633 } 632 }
634 633
635 void SimpleSynchronousEntry::Doom() const { 634 void SimpleSynchronousEntry::Doom() const {
636 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. 635 // TODO(gavinp): Consider if we should guard against redundant Doom() calls.
637 DeleteFilesForEntryHash(path_, entry_hash_); 636 DeleteFilesForEntryHash(path_, entry_hash_);
638 } 637 }
639 638
640 } // namespace disk_cache 639 } // namespace disk_cache
OLDNEW
« net/disk_cache/simple/simple_entry_impl.h ('K') | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698