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

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

Issue 12277004: Make SimpleEntryImpl::Close asynchronous. (Closed) Base URL: http://git.chromium.org/git/chromium.git@3-doomdoom
Patch Set: rebase 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
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68f65dc12f8e1c5e4bf4bac22270844bc943dbb6..3bb42b6ee7cabe5c5c51371719f4f4ec2369d838 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -86,17 +86,12 @@ void SimpleEntryImpl::Doom() {
}
void SimpleEntryImpl::Close() {
- if (synchronous_entry_in_use_by_worker_) {
- NOTIMPLEMENTED();
- delete this;
- return;
+ if (!synchronous_entry_in_use_by_worker_) {
+ WorkerPool::PostTask(FROM_HERE,
+ base::Bind(&SimpleSynchronousEntry::Close,
+ base::Unretained(synchronous_entry_)),
+ true);
}
- DCHECK(synchronous_entry_);
- WorkerPool::PostTask(FROM_HERE,
- base::Bind(&SimpleSynchronousEntry::Close,
- base::Unretained(synchronous_entry_)),
- true);
- synchronous_entry_ = NULL;
// Entry::Close() is expected to release this entry. See disk_cache.h for
// details.
delete this;
@@ -125,7 +120,8 @@ int SimpleEntryImpl::ReadData(int index,
const CompletionCallback& callback) {
// TODO(gavinp): Add support for overlapping reads. The net::HttpCache does
// make overlapping read requests when multiple transactions access the same
- // entry as read only.
+ // entry as read only. This might make calling SimpleSynchronousEntry::Close()
+ // correctly more tricky (see SimpleEntryImpl::EntryOperationComplete).
if (synchronous_entry_in_use_by_worker_) {
NOTIMPLEMENTED();
CHECK(false);
@@ -133,7 +129,7 @@ int SimpleEntryImpl::ReadData(int index,
synchronous_entry_in_use_by_worker_ = true;
SynchronousOperationCallback sync_operation_callback =
base::Bind(&SimpleEntryImpl::EntryOperationComplete,
- callback, weak_ptr_factory_.GetWeakPtr());
+ callback, weak_ptr_factory_.GetWeakPtr(), synchronous_entry_);
WorkerPool::PostTask(FROM_HERE,
base::Bind(&SimpleSynchronousEntry::ReadData,
base::Unretained(synchronous_entry_),
@@ -156,7 +152,7 @@ int SimpleEntryImpl::WriteData(int index,
synchronous_entry_in_use_by_worker_ = true;
SynchronousOperationCallback sync_operation_callback =
base::Bind(&SimpleEntryImpl::EntryOperationComplete,
- callback, weak_ptr_factory_.GetWeakPtr());
+ callback, weak_ptr_factory_.GetWeakPtr(), synchronous_entry_);
WorkerPool::PostTask(FROM_HERE,
base::Bind(&SimpleSynchronousEntry::WriteData,
base::Unretained(synchronous_entry_),
@@ -241,11 +237,20 @@ void SimpleEntryImpl::CreationOperationComplete(
void SimpleEntryImpl::EntryOperationComplete(
const CompletionCallback& completion_callback,
base::WeakPtr<SimpleEntryImpl> entry,
+ SimpleSynchronousEntry* sync_entry,
int result) {
if (entry) {
DCHECK(entry->synchronous_entry_in_use_by_worker_);
entry->synchronous_entry_in_use_by_worker_ = false;
entry->SetSynchronousData();
+ } else {
+ // |entry| must have had Close() called while this operation was in flight.
+ // Since at present only one pending entry operation can be in flight at a
pasko-google - do not use 2013/02/26 00:38:19 I'd prefer to rephrase: since the simple cache now
gavinp 2013/02/26 16:22:04 Done.
+ // time, it's safe to now call Close() on |sync|entry|.
pasko-google - do not use 2013/02/26 00:38:19 s/sync[|]entry/sync_entry/
gavinp 2013/02/26 16:22:04 Done.
+ WorkerPool::PostTask(FROM_HERE,
+ base::Bind(&SimpleSynchronousEntry::Close,
+ base::Unretained(sync_entry)),
+ true);
}
completion_callback.Run(result);
}
« 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