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_TASK_QUEUE_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
7 | 7 |
8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
9 #include "base/debug/task_annotator.h" | 9 #include "base/debug/task_annotator.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/pending_task.h" | 13 #include "base/pending_task.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "content/child/scheduler/task_queue_selector.h" | 17 #include "components/scheduler/child/task_queue_selector.h" |
18 #include "content/child/scheduler/time_source.h" | 18 #include "components/scheduler/child/time_source.h" |
19 #include "content/common/content_export.h" | 19 #include "components/scheduler/scheduler_export.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 namespace trace_event { | 22 namespace trace_event { |
23 class ConvertableToTraceFormat; | 23 class ConvertableToTraceFormat; |
24 class TracedValue; | 24 class TracedValue; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 namespace content { | 28 namespace scheduler { |
29 namespace internal { | 29 namespace internal { |
30 class LazyNow; | 30 class LazyNow; |
31 class TaskQueue; | 31 class TaskQueue; |
32 } | 32 } |
33 class NestableSingleThreadTaskRunner; | 33 class NestableSingleThreadTaskRunner; |
34 class TaskQueueSelector; | 34 class TaskQueueSelector; |
35 class TimeSource; | 35 class TimeSource; |
36 | 36 |
37 // The task queue manager provides N task queues and a selector interface for | 37 // The task queue manager provides N task queues and a selector interface for |
38 // choosing which task queue to service next. Each task queue consists of two | 38 // choosing which task queue to service next. Each task queue consists of two |
39 // sub queues: | 39 // sub queues: |
40 // | 40 // |
41 // 1. Incoming task queue. Tasks that are posted get immediately appended here. | 41 // 1. Incoming task queue. Tasks that are posted get immediately appended here. |
42 // When a task is appended into an empty incoming queue, the task manager | 42 // When a task is appended into an empty incoming queue, the task manager |
43 // work function (DoWork) is scheduled to run on the main task runner. | 43 // work function (DoWork) is scheduled to run on the main task runner. |
44 // | 44 // |
45 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from | 45 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from |
46 // the incoming task queue (if any) are moved here. The work queues are | 46 // the incoming task queue (if any) are moved here. The work queues are |
47 // registered with the selector as input to the scheduling decision. | 47 // registered with the selector as input to the scheduling decision. |
48 // | 48 // |
49 class CONTENT_EXPORT TaskQueueManager | 49 class SCHEDULER_EXPORT TaskQueueManager : public TaskQueueSelector::Observer { |
50 : public TaskQueueSelector::Observer { | |
51 public: | 50 public: |
52 // Keep TaskQueue::PumpPolicyToString in sync with this enum. | 51 // Keep TaskQueue::PumpPolicyToString in sync with this enum. |
53 enum class PumpPolicy { | 52 enum class PumpPolicy { |
54 // Tasks posted to an incoming queue with an AUTO pump policy will be | 53 // Tasks posted to an incoming queue with an AUTO pump policy will be |
55 // automatically scheduled for execution or transferred to the work queue | 54 // automatically scheduled for execution or transferred to the work queue |
56 // automatically. | 55 // automatically. |
57 AUTO, | 56 AUTO, |
58 // Tasks posted to an incoming queue with an AFTER_WAKEUP pump policy | 57 // Tasks posted to an incoming queue with an AFTER_WAKEUP pump policy |
59 // will be scheduled for execution or transferred to the work queue | 58 // will be scheduled for execution or transferred to the work queue |
60 // automatically but only after another queue has executed a task. | 59 // automatically but only after another queue has executed a task. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 213 ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
215 | 214 |
216 const char* disabled_by_default_tracing_category_; | 215 const char* disabled_by_default_tracing_category_; |
217 | 216 |
218 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 217 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
219 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 218 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
220 | 219 |
221 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 220 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
222 }; | 221 }; |
223 | 222 |
224 } // namespace content | 223 } // namespace scheduler |
225 | 224 |
226 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 225 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
OLD | NEW |