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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // Only here because base::TaskRunner requires it, the return | 48 // Only here because base::TaskRunner requires it, the return |
49 // value is hard coded to true, do not rely on this method. | 49 // value is hard coded to true, do not rely on this method. |
50 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 50 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; |
51 | 51 |
52 // DEPRECATED: Only here because base::TaskRunner requires it, implemented | 52 // DEPRECATED: Only here because base::TaskRunner requires it, implemented |
53 // by calling the virtual PostDelayedTask(..., TimeDelta) variant. | 53 // by calling the virtual PostDelayedTask(..., TimeDelta) variant. |
54 virtual bool PostDelayedTask( | 54 virtual bool PostDelayedTask( |
55 const tracked_objects::Location& from_here, | 55 const tracked_objects::Location& from_here, |
56 const base::Closure& task, | 56 const base::Closure& task, |
57 int64 delay_ms) OVERRIDE; | 57 int64 delay_ms) OVERRIDE; |
| 58 |
| 59 protected: |
| 60 virtual ~DomStorageTaskRunner() {} |
58 }; | 61 }; |
59 | 62 |
60 // A derived class used in chromium that utilizes a SequenceWorkerPool | 63 // A derived class used in chromium that utilizes a SequenceWorkerPool |
61 // under dom_storage specific SequenceTokens. The |delayed_task_loop| | 64 // under dom_storage specific SequenceTokens. The |delayed_task_loop| |
62 // is used to delay scheduling on the worker pool. | 65 // is used to delay scheduling on the worker pool. |
63 class DomStorageWorkerPoolTaskRunner : public DomStorageTaskRunner { | 66 class DomStorageWorkerPoolTaskRunner : public DomStorageTaskRunner { |
64 public: | 67 public: |
65 DomStorageWorkerPoolTaskRunner( | 68 DomStorageWorkerPoolTaskRunner( |
66 base::SequencedWorkerPool* sequenced_worker_pool, | 69 base::SequencedWorkerPool* sequenced_worker_pool, |
67 base::SequencedWorkerPool::SequenceToken primary_sequence_token, | 70 base::SequencedWorkerPool::SequenceToken primary_sequence_token, |
68 base::SequencedWorkerPool::SequenceToken commit_sequence_token, | 71 base::SequencedWorkerPool::SequenceToken commit_sequence_token, |
69 base::MessageLoopProxy* delayed_task_loop); | 72 base::MessageLoopProxy* delayed_task_loop); |
70 | 73 |
71 virtual bool PostDelayedTask( | 74 virtual bool PostDelayedTask( |
72 const tracked_objects::Location& from_here, | 75 const tracked_objects::Location& from_here, |
73 const base::Closure& task, | 76 const base::Closure& task, |
74 base::TimeDelta delay) OVERRIDE; | 77 base::TimeDelta delay) OVERRIDE; |
75 | 78 |
76 virtual bool PostShutdownBlockingTask( | 79 virtual bool PostShutdownBlockingTask( |
77 const tracked_objects::Location& from_here, | 80 const tracked_objects::Location& from_here, |
78 SequenceID sequence_id, | 81 SequenceID sequence_id, |
79 const base::Closure& task) OVERRIDE; | 82 const base::Closure& task) OVERRIDE; |
80 | 83 |
| 84 protected: |
| 85 virtual ~DomStorageWorkerPoolTaskRunner(); |
| 86 |
81 private: | 87 private: |
82 virtual ~DomStorageWorkerPoolTaskRunner(); | |
83 const scoped_refptr<base::MessageLoopProxy> message_loop_; | 88 const scoped_refptr<base::MessageLoopProxy> message_loop_; |
84 const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; | 89 const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; |
85 base::SequencedWorkerPool::SequenceToken primary_sequence_token_; | 90 base::SequencedWorkerPool::SequenceToken primary_sequence_token_; |
86 base::SequencedWorkerPool::SequenceToken commit_sequence_token_; | 91 base::SequencedWorkerPool::SequenceToken commit_sequence_token_; |
87 }; | 92 }; |
88 | 93 |
89 // A derived class used in unit tests that ignores all delays so | 94 // A derived class used in unit tests that ignores all delays so |
90 // we don't block in unit tests waiting for timeouts to expire. | 95 // we don't block in unit tests waiting for timeouts to expire. |
91 // There is no distinction between [non]-shutdown-blocking or | 96 // There is no distinction between [non]-shutdown-blocking or |
92 // the primary sequence vs the commit sequence in the mock, | 97 // the primary sequence vs the commit sequence in the mock, |
93 // all tasks are scheduled on |message_loop| with zero delay. | 98 // all tasks are scheduled on |message_loop| with zero delay. |
94 class MockDomStorageTaskRunner : public DomStorageTaskRunner { | 99 class MockDomStorageTaskRunner : public DomStorageTaskRunner { |
95 public: | 100 public: |
96 explicit MockDomStorageTaskRunner(base::MessageLoopProxy* message_loop); | 101 explicit MockDomStorageTaskRunner(base::MessageLoopProxy* message_loop); |
97 | 102 |
98 virtual bool PostDelayedTask( | 103 virtual bool PostDelayedTask( |
99 const tracked_objects::Location& from_here, | 104 const tracked_objects::Location& from_here, |
100 const base::Closure& task, | 105 const base::Closure& task, |
101 base::TimeDelta delay) OVERRIDE; | 106 base::TimeDelta delay) OVERRIDE; |
102 | 107 |
103 virtual bool PostShutdownBlockingTask( | 108 virtual bool PostShutdownBlockingTask( |
104 const tracked_objects::Location& from_here, | 109 const tracked_objects::Location& from_here, |
105 SequenceID sequence_id, | 110 SequenceID sequence_id, |
106 const base::Closure& task) OVERRIDE; | 111 const base::Closure& task) OVERRIDE; |
107 | 112 |
| 113 protected: |
| 114 virtual ~MockDomStorageTaskRunner(); |
| 115 |
108 private: | 116 private: |
109 virtual ~MockDomStorageTaskRunner(); | |
110 const scoped_refptr<base::MessageLoopProxy> message_loop_; | 117 const scoped_refptr<base::MessageLoopProxy> message_loop_; |
111 }; | 118 }; |
112 | 119 |
113 } // namespace dom_storage | 120 } // namespace dom_storage |
114 | 121 |
115 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ | 122 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ |
OLD | NEW |