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

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

Issue 23823002: Don't doom the wrong simple cache entry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: enable one more test 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
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_entry_impl.h" 5 #include "net/disk_cache/simple/simple_entry_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // have the entry in the index but we don't have the created files yet, this 246 // have the entry in the index but we don't have the created files yet, this
247 // way we never leak files. CreationOperationComplete will remove the entry 247 // way we never leak files. CreationOperationComplete will remove the entry
248 // from the index if the creation fails. 248 // from the index if the creation fails.
249 backend_->index()->Insert(entry_hash_); 249 backend_->index()->Insert(entry_hash_);
250 250
251 RunNextOperationIfNeeded(); 251 RunNextOperationIfNeeded();
252 return ret_value; 252 return ret_value;
253 } 253 }
254 254
255 int SimpleEntryImpl::DoomEntry(const CompletionCallback& callback) { 255 int SimpleEntryImpl::DoomEntry(const CompletionCallback& callback) {
256 if (doomed_)
257 return net::OK;
256 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_CALL); 258 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_CALL);
257 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_BEGIN); 259 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_BEGIN);
258 260
259 MarkAsDoomed(); 261 MarkAsDoomed();
260 pending_operations_.push(SimpleEntryOperation::DoomOperation(this, callback)); 262 pending_operations_.push(SimpleEntryOperation::DoomOperation(this, callback));
261 RunNextOperationIfNeeded(); 263 RunNextOperationIfNeeded();
262 return net::ERR_IO_PENDING; 264 return net::ERR_IO_PENDING;
263 } 265 }
264 266
265 void SimpleEntryImpl::SetKey(const std::string& key) { 267 void SimpleEntryImpl::SetKey(const std::string& key) {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 *out_entry = this; 524 *out_entry = this;
523 } 525 }
524 526
525 void SimpleEntryImpl::RemoveSelfFromBackend() { 527 void SimpleEntryImpl::RemoveSelfFromBackend() {
526 if (!backend_.get()) 528 if (!backend_.get())
527 return; 529 return;
528 backend_->OnDeactivated(this); 530 backend_->OnDeactivated(this);
529 } 531 }
530 532
531 void SimpleEntryImpl::MarkAsDoomed() { 533 void SimpleEntryImpl::MarkAsDoomed() {
534 doomed_ = true;
532 if (!backend_.get()) 535 if (!backend_.get())
533 return; 536 return;
534 doomed_ = true;
535 backend_->index()->Remove(entry_hash_); 537 backend_->index()->Remove(entry_hash_);
536 RemoveSelfFromBackend(); 538 RemoveSelfFromBackend();
537 } 539 }
538 540
539 void SimpleEntryImpl::RunNextOperationIfNeeded() { 541 void SimpleEntryImpl::RunNextOperationIfNeeded() {
540 DCHECK(io_thread_checker_.CalledOnValidThread()); 542 DCHECK(io_thread_checker_.CalledOnValidThread());
541 SIMPLE_CACHE_UMA(CUSTOM_COUNTS, 543 SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
542 "EntryOperationsPending", cache_type_, 544 "EntryOperationsPending", cache_type_,
543 pending_operations_.size(), 0, 100, 20); 545 pending_operations_.size(), 0, 100, 20);
544 if (!pending_operations_.empty() && state_ != STATE_IO_PENDING) { 546 if (!pending_operations_.empty() && state_ != STATE_IO_PENDING) {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 type = conflicting ? WRITE_FOLLOWS_CONFLICTING_WRITE 1227 type = conflicting ? WRITE_FOLLOWS_CONFLICTING_WRITE
1226 : WRITE_FOLLOWS_NON_CONFLICTING_WRITE; 1228 : WRITE_FOLLOWS_NON_CONFLICTING_WRITE;
1227 } 1229 }
1228 } 1230 }
1229 SIMPLE_CACHE_UMA(ENUMERATION, 1231 SIMPLE_CACHE_UMA(ENUMERATION,
1230 "WriteDependencyType", cache_type_, 1232 "WriteDependencyType", cache_type_,
1231 type, WRITE_DEPENDENCY_TYPE_MAX); 1233 type, WRITE_DEPENDENCY_TYPE_MAX);
1232 } 1234 }
1233 1235
1234 } // namespace disk_cache 1236 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698