OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ |
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/threading/sequenced_worker_pool.h" | 11 #include "base/threading/sequenced_worker_pool.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class MessageLoopProxy; | 15 class MessageLoopProxy; |
16 } | 16 } |
17 | 17 |
18 namespace dom_storage { | 18 namespace dom_storage { |
19 | 19 |
20 // DomStorage uses two task sequences (primary vs commit) to avoid | 20 // DomStorage uses two task sequences (primary vs commit) to avoid |
21 // primary access from queuing up behind commits to disk. | 21 // primary access from queuing up behind commits to disk. |
22 // * Initialization, shutdown, and administrative tasks are performed as | 22 // * Initialization, shutdown, and administrative tasks are performed as |
23 // shutdown-blocking primary sequence tasks. | 23 // shutdown-blocking primary sequence tasks. |
24 // * Methods that return values to the javascript'able interface are performed | 24 // * Tasks directly related to the javascript'able interface are performed |
25 // as non-shutdown-blocking primary sequence tasks. | 25 // as shutdown-blocking primary sequence tasks. |
26 // * Internal tasks related to committing changes to disk are performed as | 26 // * Internal tasks related to committing changes to disk are performed as |
27 // shutdown-blocking commit sequence tasks. | 27 // shutdown-blocking commit sequence tasks. |
28 class DomStorageTaskRunner : public base::TaskRunner { | 28 class DomStorageTaskRunner : public base::TaskRunner { |
29 public: | 29 public: |
30 enum SequenceID { | 30 enum SequenceID { |
31 PRIMARY_SEQUENCE, | 31 PRIMARY_SEQUENCE, |
32 COMMIT_SEQUENCE | 32 COMMIT_SEQUENCE |
33 }; | 33 }; |
34 | 34 |
35 // The PostTask() and PostDelayedTask() methods defined by TaskRunner | 35 // The PostTask() and PostDelayedTask() methods defined by TaskRunner |
36 // post non-shutdown-blocking tasks on the primary sequence. | 36 // post shutdown-blocking tasks on the primary sequence. |
37 virtual bool PostDelayedTask( | 37 virtual bool PostDelayedTask( |
38 const tracked_objects::Location& from_here, | 38 const tracked_objects::Location& from_here, |
39 const base::Closure& task, | 39 const base::Closure& task, |
40 base::TimeDelta delay) = 0; | 40 base::TimeDelta delay) = 0; |
41 | 41 |
42 // Posts a shutdown blocking task to |sequence_id|. | 42 // Posts a shutdown blocking task to |sequence_id|. |
43 virtual bool PostShutdownBlockingTask( | 43 virtual bool PostShutdownBlockingTask( |
44 const tracked_objects::Location& from_here, | 44 const tracked_objects::Location& from_here, |
45 SequenceID sequence_id, | 45 SequenceID sequence_id, |
46 const base::Closure& task) = 0; | 46 const base::Closure& task) = 0; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 protected: | 129 protected: |
130 virtual ~MockDomStorageTaskRunner(); | 130 virtual ~MockDomStorageTaskRunner(); |
131 | 131 |
132 private: | 132 private: |
133 const scoped_refptr<base::MessageLoopProxy> message_loop_; | 133 const scoped_refptr<base::MessageLoopProxy> message_loop_; |
134 }; | 134 }; |
135 | 135 |
136 } // namespace dom_storage | 136 } // namespace dom_storage |
137 | 137 |
138 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ | 138 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ |
OLD | NEW |