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

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

Issue 12226095: Make synchronous methods on disk_cache::SimpleEntryImpl() reentrant. (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 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 0639b942f6e17f8d5db7cdeb2a67f8070a959a70..b2757517596812390a0ffdbc733108f0d606df07 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -211,32 +211,17 @@ std::string SimpleEntryImpl::GetKey() const {
Time SimpleEntryImpl::GetLastUsed() const {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!synchronous_entry_) {
- NOTIMPLEMENTED() << ": Synchronous operations overlapping an asynchronous "
- << "operation.";
- NOTREACHED();
- }
- return synchronous_entry_->last_used();
felipeg 2013/02/12 14:47:48 If we never set synchronous_entry_ to NULL as my c
pasko-google - do not use 2013/02/12 15:07:12 I disagree. Data races are never a good excuse for
+ return last_used_;
}
Time SimpleEntryImpl::GetLastModified() const {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!synchronous_entry_) {
- NOTIMPLEMENTED() << ": Synchronous operations overlapping an asynchronous "
- << "operation.";
- NOTREACHED();
- }
- return synchronous_entry_->last_modified();
+ return last_modified_;
}
int32 SimpleEntryImpl::GetDataSize(int index) const {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!synchronous_entry_) {
- NOTIMPLEMENTED() << ": Synchronous operations overlapping an asynchronous "
- << "operation.";
- NOTREACHED();
- }
- return synchronous_entry_->data_size(index);
+ return data_size_[index];
}
int SimpleEntryImpl::ReadData(int index,
@@ -337,10 +322,11 @@ int SimpleEntryImpl::ReadyForSparseIO(const CompletionCallback& callback) {
SimpleEntryImpl::SimpleEntryImpl(
SimpleSynchronousEntry* synchronous_entry)
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
+ path_(synchronous_entry->path()),
key_(synchronous_entry->key()),
- synchronous_entry_(synchronous_entry),
+ synchronous_entry_(NULL),
has_been_doomed_(false) {
- DCHECK(synchronous_entry);
+ SetSynchronousEntry(synchronous_entry);
}
SimpleEntryImpl::~SimpleEntryImpl() {
@@ -359,6 +345,10 @@ void SimpleEntryImpl::SetSynchronousEntry(
SimpleSynchronousEntry* synchronous_entry) {
DCHECK(!synchronous_entry_) << "synchronous_entry_ = " << synchronous_entry_;
synchronous_entry_ = synchronous_entry;
+ last_used_ = synchronous_entry_->last_used();
+ last_modified_ = synchronous_entry_->last_modified();
+ for (int i = 0; i < kSimpleEntryFileCount; ++i)
+ data_size_[i] = synchronous_entry_->data_size(i);
}
} // namespace disk_cache

Powered by Google App Engine
This is Rietveld 408576698