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

Unified Diff: net/disk_cache/simple/simple_entry_impl.cc

Issue 23486006: Track entries pending Doom in SimpleCache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediation and test update Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/simple/simple_entry_impl.cc
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 04d2ce99ab7f5d11ed40e2e1fcf0a3dbc2196667..379b5877f4942c89e99abc81cbb3bc295b9c063e 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -164,6 +164,7 @@ SimpleEntryImpl::SimpleEntryImpl(const FilePath& path,
last_used_(Time::Now()),
last_modified_(last_used_),
open_count_(0),
+ doomed_(false),
state_(STATE_UNINITIALIZED),
synchronous_entry_(NULL),
net_log_(net::BoundNetLog::Make(
@@ -527,12 +528,12 @@ void SimpleEntryImpl::RemoveSelfFromBackend() {
if (!backend_.get())
return;
backend_->OnDeactivated(this);
- backend_.reset();
}
void SimpleEntryImpl::MarkAsDoomed() {
if (!backend_.get())
return;
+ doomed_ = true;
backend_->index()->Remove(entry_hash_);
RemoveSelfFromBackend();
}
@@ -779,7 +780,7 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index,
buf_len = std::min(buf_len, GetDataSize(stream_index) - offset);
state_ = STATE_IO_PENDING;
- if (backend_.get())
+ if (!doomed_ && backend_.get())
backend_->index()->UseIfExists(entry_hash_);
scoped_ptr<uint32> read_crc32(new uint32());
@@ -839,7 +840,7 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index,
DCHECK_EQ(STATE_READY, state_);
state_ = STATE_IO_PENDING;
- if (backend_.get())
+ if (!doomed_ && backend_.get())
backend_->index()->UseIfExists(entry_hash_);
// It is easy to incrementally compute the CRC from [0 .. |offset + buf_len|)
// if |offset == 0| or we have already computed the CRC for [0 .. offset).
@@ -891,6 +892,8 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index,
}
void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) {
+ if (backend_)
+ backend_->OnDoomStart(entry_hash_);
PostTaskAndReplyWithResult(
worker_pool_, FROM_HERE,
base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, key_, entry_hash_),
@@ -1069,13 +1072,16 @@ void SimpleEntryImpl::WriteOperationComplete(
stream_index, completion_callback, *entry_stat, result.Pass());
}
-void SimpleEntryImpl::DoomOperationComplete(const CompletionCallback& callback,
- State state_to_restore,
- int result) {
+void SimpleEntryImpl::DoomOperationComplete(
+ const CompletionCallback& callback,
+ State state_to_restore,
+ int result) {
state_ = state_to_restore;
if (!callback.is_null())
callback.Run(result);
RunNextOperationIfNeeded();
+ if (backend_)
+ backend_->OnDoomComplete(entry_hash_);
}
void SimpleEntryImpl::ChecksumOperationComplete(
@@ -1137,7 +1143,7 @@ void SimpleEntryImpl::UpdateDataFromEntryStat(
for (int i = 0; i < kSimpleEntryFileCount; ++i) {
data_size_[i] = entry_stat.data_size[i];
}
- if (backend_.get())
+ if (!doomed_ && backend_.get())
backend_->index()->UpdateEntrySize(entry_hash_, GetDiskUsage());
}
« net/disk_cache/simple/simple_backend_impl.cc ('K') | « 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