OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
11 #include "base/debug/task_annotator.h" | 11 #include "base/debug/task_annotator.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/pending_task.h" | 15 #include "base/pending_task.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "components/scheduler/base/enqueue_order.h" | 18 #include "platform/scheduler/base/enqueue_order.h" |
19 #include "components/scheduler/base/task_queue_impl.h" | 19 #include "platform/scheduler/base/task_queue_impl.h" |
20 #include "components/scheduler/base/task_queue_selector.h" | 20 #include "platform/scheduler/base/task_queue_selector.h" |
21 #include "components/scheduler/scheduler_export.h" | |
22 | 21 |
23 namespace base { | 22 namespace base { |
24 class TickClock; | 23 class TickClock; |
25 | 24 |
26 namespace trace_event { | 25 namespace trace_event { |
27 class ConvertableToTraceFormat; | 26 class ConvertableToTraceFormat; |
28 class TracedValue; | 27 class TracedValue; |
29 } // namespace trace_event | 28 } // namespace trace_event |
30 } // namespace base | 29 } // namespace base |
31 | 30 |
| 31 namespace blink { |
32 namespace scheduler { | 32 namespace scheduler { |
33 namespace internal { | 33 namespace internal { |
34 class TaskQueueImpl; | 34 class TaskQueueImpl; |
35 } // namespace internal | 35 } // namespace internal |
36 | 36 |
37 class LazyNow; | 37 class LazyNow; |
38 class RealTimeDomain; | 38 class RealTimeDomain; |
39 class TimeDomain; | 39 class TimeDomain; |
40 class TaskQueueManagerDelegate; | 40 class TaskQueueManagerDelegate; |
41 class TaskTimeTracker; | 41 class TaskTimeTracker; |
42 | 42 |
43 // The task queue manager provides N task queues and a selector interface for | 43 // The task queue manager provides N task queues and a selector interface for |
44 // choosing which task queue to service next. Each task queue consists of two | 44 // choosing which task queue to service next. Each task queue consists of two |
45 // sub queues: | 45 // sub queues: |
46 // | 46 // |
47 // 1. Incoming task queue. Tasks that are posted get immediately appended here. | 47 // 1. Incoming task queue. Tasks that are posted get immediately appended here. |
48 // When a task is appended into an empty incoming queue, the task manager | 48 // When a task is appended into an empty incoming queue, the task manager |
49 // work function (DoWork) is scheduled to run on the main task runner. | 49 // work function (DoWork) is scheduled to run on the main task runner. |
50 // | 50 // |
51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from | 51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from |
52 // the incoming task queue (if any) are moved here. The work queues are | 52 // the incoming task queue (if any) are moved here. The work queues are |
53 // registered with the selector as input to the scheduling decision. | 53 // registered with the selector as input to the scheduling decision. |
54 // | 54 // |
55 class SCHEDULER_EXPORT TaskQueueManager | 55 class BLINK_PLATFORM_EXPORT TaskQueueManager |
56 : public internal::TaskQueueSelector::Observer { | 56 : public internal::TaskQueueSelector::Observer { |
57 public: | 57 public: |
58 // Create a task queue manager where |delegate| identifies the thread | 58 // Create a task queue manager where |delegate| identifies the thread |
59 // on which where the tasks are eventually run. Category strings must have | 59 // on which where the tasks are eventually run. Category strings must have |
60 // application lifetime (statics or literals). They may not include " chars. | 60 // application lifetime (statics or literals). They may not include " chars. |
61 TaskQueueManager(scoped_refptr<TaskQueueManagerDelegate> delegate, | 61 TaskQueueManager(scoped_refptr<TaskQueueManagerDelegate> delegate, |
62 const char* tracing_category, | 62 const char* tracing_category, |
63 const char* disabled_by_default_tracing_category, | 63 const char* disabled_by_default_tracing_category, |
64 const char* disabled_by_default_verbose_tracing_category); | 64 const char* disabled_by_default_verbose_tracing_category); |
65 ~TaskQueueManager() override; | 65 ~TaskQueueManager() override; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Returns true if any task from a monitored task queue was was run since the | 98 // Returns true if any task from a monitored task queue was was run since the |
99 // last call to GetAndClearSystemIsQuiescentBit. | 99 // last call to GetAndClearSystemIsQuiescentBit. |
100 bool GetAndClearSystemIsQuiescentBit(); | 100 bool GetAndClearSystemIsQuiescentBit(); |
101 | 101 |
102 // Creates a task queue with the given |spec|. Must be called on the thread | 102 // Creates a task queue with the given |spec|. Must be called on the thread |
103 // this class was created on. | 103 // this class was created on. |
104 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( | 104 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( |
105 const TaskQueue::Spec& spec); | 105 const TaskQueue::Spec& spec); |
106 | 106 |
107 class SCHEDULER_EXPORT Observer { | 107 class BLINK_PLATFORM_EXPORT Observer { |
108 public: | 108 public: |
109 virtual ~Observer() {} | 109 virtual ~Observer() {} |
110 | 110 |
111 // Called when |queue| is unregistered. | 111 // Called when |queue| is unregistered. |
112 virtual void OnUnregisterTaskQueue( | 112 virtual void OnUnregisterTaskQueue( |
113 const scoped_refptr<TaskQueue>& queue) = 0; | 113 const scoped_refptr<TaskQueue>& queue) = 0; |
114 | 114 |
115 // Called when the manager tried to execute a task from a disabled | 115 // Called when the manager tried to execute a task from a disabled |
116 // queue. See TaskQueue::Spec::SetShouldReportWhenExecutionBlocked. | 116 // queue. See TaskQueue::Spec::SetShouldReportWhenExecutionBlocked. |
117 virtual void OnTriedToExecuteBlockedTask(const TaskQueue& queue, | 117 virtual void OnTriedToExecuteBlockedTask(const TaskQueue& queue, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED | 257 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED |
258 | 258 |
259 Observer* observer_; // NOT OWNED | 259 Observer* observer_; // NOT OWNED |
260 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 260 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
262 | 262 |
263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
264 }; | 264 }; |
265 | 265 |
266 } // namespace scheduler | 266 } // namespace scheduler |
| 267 } // namespace blink |
267 | 268 |
268 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 269 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_
H_ |
OLD | NEW |