OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequence_checker.h" | 10 #include "base/sequence_checker.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 : public base::TaskRunner { | 27 : public base::TaskRunner { |
28 public: | 28 public: |
29 enum SequenceID { | 29 enum SequenceID { |
30 PRIMARY_SEQUENCE, | 30 PRIMARY_SEQUENCE, |
31 COMMIT_SEQUENCE | 31 COMMIT_SEQUENCE |
32 }; | 32 }; |
33 | 33 |
34 // The PostTask() and PostDelayedTask() methods defined by TaskRunner | 34 // The PostTask() and PostDelayedTask() methods defined by TaskRunner |
35 // post shutdown-blocking tasks on the primary sequence. | 35 // post shutdown-blocking tasks on the primary sequence. |
36 bool PostDelayedTask(const tracked_objects::Location& from_here, | 36 bool PostDelayedTask(const tracked_objects::Location& from_here, |
37 base::Closure task, | 37 base::OnceClosure task, |
38 base::TimeDelta delay) override = 0; | 38 base::TimeDelta delay) override = 0; |
39 | 39 |
40 // Posts a shutdown blocking task to |sequence_id|. | 40 // Posts a shutdown blocking task to |sequence_id|. |
41 virtual bool PostShutdownBlockingTask( | 41 virtual bool PostShutdownBlockingTask( |
42 const tracked_objects::Location& from_here, | 42 const tracked_objects::Location& from_here, |
43 SequenceID sequence_id, | 43 SequenceID sequence_id, |
44 base::Closure task) = 0; | 44 base::OnceClosure task) = 0; |
45 | 45 |
46 virtual void AssertIsRunningOnPrimarySequence() const = 0; | 46 virtual void AssertIsRunningOnPrimarySequence() const = 0; |
47 virtual void AssertIsRunningOnCommitSequence() const = 0; | 47 virtual void AssertIsRunningOnCommitSequence() const = 0; |
48 | 48 |
49 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( | 49 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( |
50 SequenceID sequence_id) = 0; | 50 SequenceID sequence_id) = 0; |
51 | 51 |
52 protected: | 52 protected: |
53 ~DOMStorageTaskRunner() override {} | 53 ~DOMStorageTaskRunner() override {} |
54 }; | 54 }; |
55 | 55 |
56 // A DOMStorageTaskRunner which manages a primary and a commit sequence. | 56 // A DOMStorageTaskRunner which manages a primary and a commit sequence. |
57 class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : | 57 class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : |
58 public DOMStorageTaskRunner { | 58 public DOMStorageTaskRunner { |
59 public: | 59 public: |
60 // |primary_sequence| and |commit_sequence| should have | 60 // |primary_sequence| and |commit_sequence| should have |
61 // TaskShutdownBehaviour::BLOCK_SHUTDOWN semantics. | 61 // TaskShutdownBehaviour::BLOCK_SHUTDOWN semantics. |
62 DOMStorageWorkerPoolTaskRunner( | 62 DOMStorageWorkerPoolTaskRunner( |
63 scoped_refptr<base::SequencedTaskRunner> primary_sequence, | 63 scoped_refptr<base::SequencedTaskRunner> primary_sequence, |
64 scoped_refptr<base::SequencedTaskRunner> commit_sequence); | 64 scoped_refptr<base::SequencedTaskRunner> commit_sequence); |
65 | 65 |
66 bool RunsTasksOnCurrentThread() const override; | 66 bool RunsTasksOnCurrentThread() const override; |
67 | 67 |
68 bool PostDelayedTask(const tracked_objects::Location& from_here, | 68 bool PostDelayedTask(const tracked_objects::Location& from_here, |
69 base::Closure task, | 69 base::OnceClosure task, |
70 base::TimeDelta delay) override; | 70 base::TimeDelta delay) override; |
71 | 71 |
72 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, | 72 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, |
73 SequenceID sequence_id, | 73 SequenceID sequence_id, |
74 base::Closure task) override; | 74 base::OnceClosure task) override; |
75 | 75 |
76 void AssertIsRunningOnPrimarySequence() const override; | 76 void AssertIsRunningOnPrimarySequence() const override; |
77 void AssertIsRunningOnCommitSequence() const override; | 77 void AssertIsRunningOnCommitSequence() const override; |
78 | 78 |
79 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( | 79 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( |
80 SequenceID sequence_id) override; | 80 SequenceID sequence_id) override; |
81 | 81 |
82 protected: | 82 protected: |
83 ~DOMStorageWorkerPoolTaskRunner() override; | 83 ~DOMStorageWorkerPoolTaskRunner() override; |
84 | 84 |
(...skipping 11 matching lines...) Expand all Loading... |
96 // all tasks are scheduled on |task_runner| with zero delay. | 96 // all tasks are scheduled on |task_runner| with zero delay. |
97 class CONTENT_EXPORT MockDOMStorageTaskRunner : | 97 class CONTENT_EXPORT MockDOMStorageTaskRunner : |
98 public DOMStorageTaskRunner { | 98 public DOMStorageTaskRunner { |
99 public: | 99 public: |
100 explicit MockDOMStorageTaskRunner( | 100 explicit MockDOMStorageTaskRunner( |
101 scoped_refptr<base::SequencedTaskRunner> task_runner); | 101 scoped_refptr<base::SequencedTaskRunner> task_runner); |
102 | 102 |
103 bool RunsTasksOnCurrentThread() const override; | 103 bool RunsTasksOnCurrentThread() const override; |
104 | 104 |
105 bool PostDelayedTask(const tracked_objects::Location& from_here, | 105 bool PostDelayedTask(const tracked_objects::Location& from_here, |
106 base::Closure task, | 106 base::OnceClosure task, |
107 base::TimeDelta delay) override; | 107 base::TimeDelta delay) override; |
108 | 108 |
109 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, | 109 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, |
110 SequenceID sequence_id, | 110 SequenceID sequence_id, |
111 base::Closure task) override; | 111 base::OnceClosure task) override; |
112 | 112 |
113 void AssertIsRunningOnPrimarySequence() const override; | 113 void AssertIsRunningOnPrimarySequence() const override; |
114 void AssertIsRunningOnCommitSequence() const override; | 114 void AssertIsRunningOnCommitSequence() const override; |
115 | 115 |
116 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( | 116 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( |
117 SequenceID sequence_id) override; | 117 SequenceID sequence_id) override; |
118 | 118 |
119 protected: | 119 protected: |
120 ~MockDOMStorageTaskRunner() override; | 120 ~MockDOMStorageTaskRunner() override; |
121 | 121 |
122 private: | 122 private: |
123 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 123 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(MockDOMStorageTaskRunner); | 125 DISALLOW_COPY_AND_ASSIGN(MockDOMStorageTaskRunner); |
126 }; | 126 }; |
127 | 127 |
128 } // namespace content | 128 } // namespace content |
129 | 129 |
130 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ | 130 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ |
OLD | NEW |