Chromium Code Reviews| Index: webkit/dom_storage/dom_storage_task_runner.h |
| =================================================================== |
| --- webkit/dom_storage/dom_storage_task_runner.h (revision 127613) |
| +++ webkit/dom_storage/dom_storage_task_runner.h (working copy) |
| @@ -17,18 +17,27 @@ |
| namespace dom_storage { |
| -// Tasks must run serially with respect to one another, but may |
| -// execute on different OS threads. The base class is implemented |
| -// in terms of a MessageLoopProxy. |
| -class DomStorageTaskRunner : public base::SequencedTaskRunner { |
| +// Interface for posting dom storage related tasks. There |
| +// are two logical task sequences, the primary sequence is |
| +// the read where most tasks are performed, the commit sequence |
| +// is used internally for committing data to disk. The base TaskRunner |
| +// interfaces maps to the primary sequence and allow callers to post |
| +// non shutdown blocking tasks on it. An additional method allows callers |
| +// to post shutdown blocking tasks to either sequence. |
| +class DomStorageTaskRunner : public base::TaskRunner { |
| public: |
| - explicit DomStorageTaskRunner(base::MessageLoopProxy* message_loop); |
| + enum SequenceID { |
| + PRIMARY_SEQUENCE, |
| + COMMIT_SEQUENCE |
| + }; |
| + |
| virtual ~DomStorageTaskRunner(); |
| - // The PostTask() method, defined by TaskRunner, schedules a task |
| - // to run immediately. |
| + // The PostTask() method, defined by TaskRunner, schedules |
| + // a non shutdown blocking READ_SEQUENCE task to run immediately. |
|
benm (inactive)
2012/03/20 13:39:16
s/READ_/PRIMARY_/ and below
|
| - // Schedules a task to be run after a delay. |
| + // Schedules a non shutdown blocking READ_SEQUENCE task to be run |
| + // after a delay. |
| virtual bool PostDelayedTask( |
| const tracked_objects::Location& from_here, |
| const base::Closure& task, |
| @@ -45,43 +54,43 @@ |
| // value is hard coded to true. |
| virtual bool RunsTasksOnCurrentThread() const OVERRIDE; |
| - // SequencedTaskRunner overrides, these are implemented in |
| - // terms of PostDelayedTask and the latter is similarly deprecated. |
| - virtual bool PostNonNestableDelayedTask( |
| + virtual bool PostShutdownBlockingTask( |
| const tracked_objects::Location& from_here, |
| - const base::Closure& task, |
| - base::TimeDelta delay) OVERRIDE; |
| - virtual bool PostNonNestableDelayedTask( |
| - const tracked_objects::Location& from_here, |
| - const base::Closure& task, |
| - int64 delay_ms) OVERRIDE; |
| + SequenceID sequence_id, |
| + const base::Closure& task) = 0; |
| protected: |
| + explicit DomStorageTaskRunner(base::MessageLoopProxy* message_loop); |
| + |
| const scoped_refptr<base::MessageLoopProxy> message_loop_; |
| }; |
| // A derived class that utlizes the SequenceWorkerPool under a |
|
benm (inactive)
2012/03/20 13:39:16
remove "a"
|
| -// dom_storage specific SequenceToken. The MessageLoopProxy |
| +// dom_storage specific SequenceTokens. The MessageLoopProxy |
| // is used to delay scheduling on the worker pool. |
| class DomStorageWorkerPoolTaskRunner : public DomStorageTaskRunner { |
| public: |
| DomStorageWorkerPoolTaskRunner( |
| base::SequencedWorkerPool* sequenced_worker_pool, |
| - base::SequencedWorkerPool::SequenceToken sequence_token, |
| + base::SequencedWorkerPool::SequenceToken primary_sequence_token, |
| + base::SequencedWorkerPool::SequenceToken commit_sequence_token, |
| base::MessageLoopProxy* delayed_task_loop); |
| virtual ~DomStorageWorkerPoolTaskRunner(); |
| - // Schedules a sequenced worker task to be run after a delay. |
| virtual bool PostDelayedTask( |
| const tracked_objects::Location& from_here, |
| const base::Closure& task, |
| base::TimeDelta delay) OVERRIDE; |
| - base::SequencedWorkerPool::SequenceToken sequence_token() const; |
| + virtual bool PostShutdownBlockingTask( |
| + const tracked_objects::Location& from_here, |
| + SequenceID sequence_id, |
| + const base::Closure& task) OVERRIDE; |
| private: |
| const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; |
| - base::SequencedWorkerPool::SequenceToken sequence_token_; |
| + base::SequencedWorkerPool::SequenceToken primary_sequence_token_; |
| + base::SequencedWorkerPool::SequenceToken commit_sequence_token_; |
| }; |
| // A derived class used in unit tests that causes us to ignore the |
| @@ -96,6 +105,11 @@ |
| const tracked_objects::Location& from_here, |
| const base::Closure& task, |
| base::TimeDelta delay) OVERRIDE; |
| + |
| + virtual bool PostShutdownBlockingTask( |
| + const tracked_objects::Location& from_here, |
| + SequenceID sequence_id, |
| + const base::Closure& task) OVERRIDE; |
| }; |
| } // namespace dom_storage |