Chromium Code Reviews| 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..eea66e9210fc1882e7188da696b6e1a69d2c16ba 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; |
| @@ -133,7 +128,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 +151,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 +236,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 most one PendingEntryOperation can exist at a time for any entry |
|
pasko-google - do not use
2013/02/15 17:08:51
there is no class PendingEntryOperation, better wr
gavinp
2013/02/15 18:33:00
Done.
|
| + // it is safe and correct to Close() |sync_entry|. |
| + WorkerPool::PostTask(FROM_HERE, |
| + base::Bind(&SimpleSynchronousEntry::Close, |
| + base::Unretained(sync_entry)), |
| + true); |
| } |
| completion_callback.Run(result); |
| } |