Chromium Code Reviews| Index: webkit/dom_storage/dom_storage_task_runner.cc |
| =================================================================== |
| --- webkit/dom_storage/dom_storage_task_runner.cc (revision 127221) |
| +++ webkit/dom_storage/dom_storage_task_runner.cc (working copy) |
| @@ -64,6 +64,10 @@ |
| : DomStorageTaskRunner(delayed_task_loop), |
| sequenced_worker_pool_(sequenced_worker_pool), |
| sequence_token_(sequence_token) { |
| + |
| + // TODO: have ctor argument for this |
| + commit_sequence_token_ = |
| + sequenced_worker_pool->GetNamedSequenceToken("dom_storage_commit"); |
| } |
| DomStorageWorkerPoolTaskRunner::~DomStorageWorkerPoolTaskRunner() { |
| @@ -77,8 +81,7 @@ |
| // with a delay of zero, we detect that usage and avoid the unecessary |
| // trip thru the message_loop. |
| if (delay == base::TimeDelta()) { |
| - // We can skip on shutdown as the destructor of DomStorageArea will ensure |
| - // that any remaining data is committed to disk. |
| + // Nominally, tasks are posted that can be skipped during shutdown. |
| return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior( |
| sequence_token_, from_here, task, |
| base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| @@ -91,8 +94,27 @@ |
| delay); |
| } |
| -// MockDomStorageTaskRunner |
| +bool DomStorageWorkerPoolTaskRunner::PostShutdownBlockingTask( |
|
benm (inactive)
2012/03/19 14:22:53
Maybe rather than having two methods have one that
michaeln
2012/03/19 16:04:42
sgtm... PostShutdownBlockingTask(sequence_id, ...)
|
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task) { |
| + return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior( |
| + sequence_token_, from_here, task, |
| + base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| +} |
| +bool DomStorageWorkerPoolTaskRunner::PostShutdownBlockingCommitTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task) { |
| + return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior( |
| + commit_sequence_token_, from_here, task, |
| + base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| +} |
| + |
| +// MockDomStorageTaskRunner, there is no distinction between |
| +// shutdown blocking or the commit sequence vs the read sequence |
| +// in our mock, all tasks are scheduled on the provided message |
| +// loop. And delay values are all squashed to zero. |
| + |
| MockDomStorageTaskRunner::MockDomStorageTaskRunner( |
| base::MessageLoopProxy* message_loop) |
| : DomStorageTaskRunner(message_loop) { |
| @@ -102,9 +124,20 @@ |
| const tracked_objects::Location& from_here, |
| const base::Closure& task, |
| base::TimeDelta delay) { |
| - // Squash all delays to zero in our mock. |
| return DomStorageTaskRunner::PostDelayedTask( |
| from_here, task, base::TimeDelta()); |
| } |
| +bool MockDomStorageTaskRunner::PostShutdownBlockingTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task) { |
| + return PostTask(from_here, task); |
| +} |
| + |
| +bool MockDomStorageTaskRunner::PostShutdownBlockingCommitTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task) { |
| + return PostTask(from_here, task); |
| +} |
| + |
| } // namespace dom_storage |