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 72d6d4c7e104a03db5499460443afac22d7d20f9..c6b9ef5cf7edb22e8552adb3e152b713196675cd 100644 |
| --- a/net/disk_cache/simple/simple_entry_impl.cc |
| +++ b/net/disk_cache/simple/simple_entry_impl.cc |
| @@ -16,6 +16,7 @@ |
| #include "base/message_loop/message_loop_proxy.h" |
| #include "base/metrics/histogram.h" |
| #include "base/task_runner.h" |
| +#include "base/task_runner_util.h" |
| #include "base/time/time.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/net_errors.h" |
| @@ -257,12 +258,8 @@ int SimpleEntryImpl::DoomEntry(const CompletionCallback& callback) { |
| net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_DOOM_BEGIN); |
| MarkAsDoomed(); |
| - scoped_ptr<int> result(new int()); |
| - Closure task = base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, key_, |
| - entry_hash_, result.get()); |
| - Closure reply = base::Bind(&CallCompletionCallback, |
| - callback, base::Passed(&result)); |
| - worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
| + pending_operations_.push(SimpleEntryOperation::DoomOperation(this, callback)); |
| + RunNextOperationIfNeeded(); |
| return net::ERR_IO_PENDING; |
| } |
| @@ -537,7 +534,6 @@ void SimpleEntryImpl::MarkAsDoomed() { |
| if (!backend_.get()) |
| return; |
| backend_->index()->Remove(entry_hash_); |
| - RemoveSelfFromBackend(); |
|
gavinp
2013/08/26 20:36:50
There's more to it than this.
This was the only c
Philippe
2013/08/27 11:33:30
To be honest I'm a bit confused with this MarkAsDo
gavinp
2013/08/27 15:48:02
There's a member backend_ on SimpleEntryImpl, it's
Philippe
2013/08/27 16:11:21
I see now, thanks :) I hadn't understood that the
|
| } |
| void SimpleEntryImpl::RunNextOperationIfNeeded() { |
| @@ -579,6 +575,9 @@ void SimpleEntryImpl::RunNextOperationIfNeeded() { |
| operation->callback(), |
| operation->truncate()); |
| break; |
| + case SimpleEntryOperation::TYPE_DOOM: |
| + DoomEntryInternal(operation->callback()); |
| + break; |
| default: |
| NOTREACHED(); |
| } |
| @@ -890,6 +889,15 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, |
| worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
| } |
| +void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) { |
| + PostTaskAndReplyWithResult( |
|
gavinp
2013/08/26 20:36:50
Every one of the other calls has a kind of manual
Philippe
2013/08/27 11:33:30
In my opinion it would be nice to switch to PostTa
|
| + worker_pool_, FROM_HERE, |
| + base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, key_, entry_hash_), |
| + base::Bind(&SimpleEntryImpl::DoomOperationComplete, this, state_, |
| + callback)); |
| + state_ = STATE_IO_PENDING; |
| +} |
| + |
| void SimpleEntryImpl::CreationOperationComplete( |
| const CompletionCallback& completion_callback, |
| const base::TimeTicks& start_time, |
| @@ -1060,6 +1068,15 @@ void SimpleEntryImpl::WriteOperationComplete( |
| stream_index, completion_callback, *entry_stat, result.Pass()); |
| } |
| +void SimpleEntryImpl::DoomOperationComplete(State state_to_restore, |
| + const CompletionCallback& callback, |
| + int result) { |
| + state_ = state_to_restore; |
| + if (!callback.is_null()) |
| + callback.Run(result); |
| + RunNextOperationIfNeeded(); |
| +} |
| + |
| void SimpleEntryImpl::ChecksumOperationComplete( |
| int orig_result, |
| int stream_index, |