OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ | 5 #ifndef COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ |
6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ | 6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/trace_event/trace_event.h" |
11 #include "components/scheduler/scheduler_export.h" | 12 #include "components/scheduler/scheduler_export.h" |
12 | 13 |
| 14 namespace base { |
| 15 namespace trace_event { |
| 16 class BlameContext; |
| 17 } |
| 18 } |
| 19 |
13 namespace scheduler { | 20 namespace scheduler { |
14 class TimeDomain; | 21 class TimeDomain; |
15 | 22 |
16 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { | 23 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { |
17 public: | 24 public: |
18 TaskQueue() {} | 25 TaskQueue() {} |
19 | 26 |
20 // Unregisters the task queue after which no tasks posted to it will run and | 27 // Unregisters the task queue after which no tasks posted to it will run and |
21 // the TaskQueueManager's reference to it will be released soon. | 28 // the TaskQueueManager's reference to it will be released soon. |
22 virtual void UnregisterTaskQueue() = 0; | 29 virtual void UnregisterTaskQueue() = 0; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // |may_post_dowork|. | 184 // |may_post_dowork|. |
178 virtual void PumpQueue(bool may_post_dowork) = 0; | 185 virtual void PumpQueue(bool may_post_dowork) = 0; |
179 | 186 |
180 // These functions can only be called on the same thread that the task queue | 187 // These functions can only be called on the same thread that the task queue |
181 // manager executes its tasks on. | 188 // manager executes its tasks on. |
182 virtual void AddTaskObserver( | 189 virtual void AddTaskObserver( |
183 base::MessageLoop::TaskObserver* task_observer) = 0; | 190 base::MessageLoop::TaskObserver* task_observer) = 0; |
184 virtual void RemoveTaskObserver( | 191 virtual void RemoveTaskObserver( |
185 base::MessageLoop::TaskObserver* task_observer) = 0; | 192 base::MessageLoop::TaskObserver* task_observer) = 0; |
186 | 193 |
| 194 // Set the blame context which is entered and left while executing tasks from |
| 195 // this task queue. |blame_context| must be null or outlive this task queue. |
| 196 // Must be called on the thread this TaskQueue was created by. |
| 197 virtual void SetBlameContext( |
| 198 base::trace_event::BlameContext* blame_context) = 0; |
| 199 |
187 // Removes the task queue from the previous TimeDomain and adds it to | 200 // Removes the task queue from the previous TimeDomain and adds it to |
188 // |domain|. This is a moderately expensive operation. | 201 // |domain|. This is a moderately expensive operation. |
189 virtual void SetTimeDomain(TimeDomain* domain) = 0; | 202 virtual void SetTimeDomain(TimeDomain* domain) = 0; |
190 | 203 |
191 // Returns the queue's current TimeDomain. Can be called from any thread. | 204 // Returns the queue's current TimeDomain. Can be called from any thread. |
192 virtual TimeDomain* GetTimeDomain() const = 0; | 205 virtual TimeDomain* GetTimeDomain() const = 0; |
193 | 206 |
194 protected: | 207 protected: |
195 ~TaskQueue() override {} | 208 ~TaskQueue() override {} |
196 | 209 |
197 DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 210 DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
198 }; | 211 }; |
199 | 212 |
200 } // namespace scheduler | 213 } // namespace scheduler |
201 | 214 |
202 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ | 215 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ |
OLD | NEW |