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_CHILD_SCHEDULER_HELPER_H_ | 5 #ifndef COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ |
6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ | 6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ |
7 | 7 |
8 #include "components/scheduler/child/prioritizing_task_queue_selector.h" | 8 #include "components/scheduler/child/prioritizing_task_queue_selector.h" |
9 #include "components/scheduler/child/task_queue_manager.h" | 9 #include "components/scheduler/child/task_queue_manager.h" |
10 #include "components/scheduler/scheduler_export.h" | 10 #include "components/scheduler/scheduler_export.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class TickClock; | 13 class TickClock; |
14 } | 14 } |
15 | 15 |
16 namespace scheduler { | 16 namespace scheduler { |
17 | 17 |
18 class NestableSingleThreadTaskRunner; | 18 class SchedulerTaskRunnerDelegate; |
19 | 19 |
20 // Common scheduler functionality for default tasks. | 20 // Common scheduler functionality for default tasks. |
21 class SCHEDULER_EXPORT SchedulerHelper { | 21 class SCHEDULER_EXPORT SchedulerHelper { |
22 public: | 22 public: |
23 // NOTE |total_task_queue_count| must be >= TASK_QUEUE_COUNT. | 23 // NOTE |total_task_queue_count| must be >= TASK_QUEUE_COUNT. |
24 // Category strings must have application lifetime (statics or | 24 // Category strings must have application lifetime (statics or |
25 // literals). They may not include " chars. | 25 // literals). They may not include " chars. |
26 SchedulerHelper( | 26 SchedulerHelper(scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner, |
27 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, | 27 const char* tracing_category, |
28 const char* tracing_category, | 28 const char* disabled_by_default_tracing_category, |
29 const char* disabled_by_default_tracing_category, | 29 const char* disabled_by_default_verbose_tracing_category, |
30 const char* disabled_by_default_verbose_tracing_category, | 30 size_t total_task_queue_count); |
31 size_t total_task_queue_count); | |
32 ~SchedulerHelper(); | 31 ~SchedulerHelper(); |
33 | 32 |
34 // Returns the default task runner. | 33 // Returns the default task runner. |
35 scoped_refptr<TaskQueue> DefaultTaskRunner(); | 34 scoped_refptr<TaskQueue> DefaultTaskRunner(); |
36 | 35 |
37 // Returns the control task runner. Tasks posted to this runner are executed | 36 // Returns the control task runner. Tasks posted to this runner are executed |
38 // with the highest priority. Care must be taken to avoid starvation of other | 37 // with the highest priority. Care must be taken to avoid starvation of other |
39 // task queues. | 38 // task queues. |
40 scoped_refptr<base::SingleThreadTaskRunner> ControlTaskRunner(); | 39 scoped_refptr<base::SingleThreadTaskRunner> ControlTaskRunner(); |
41 | 40 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 96 |
98 // Test helpers. | 97 // Test helpers. |
99 void SetTimeSourceForTesting(scoped_ptr<base::TickClock> time_source); | 98 void SetTimeSourceForTesting(scoped_ptr<base::TickClock> time_source); |
100 void SetWorkBatchSizeForTesting(size_t work_batch_size); | 99 void SetWorkBatchSizeForTesting(size_t work_batch_size); |
101 TaskQueueManager* GetTaskQueueManagerForTesting(); | 100 TaskQueueManager* GetTaskQueueManagerForTesting(); |
102 | 101 |
103 private: | 102 private: |
104 friend class SchedulerHelperTest; | 103 friend class SchedulerHelperTest; |
105 | 104 |
106 base::ThreadChecker thread_checker_; | 105 base::ThreadChecker thread_checker_; |
| 106 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner_; |
107 scoped_ptr<PrioritizingTaskQueueSelector> task_queue_selector_; | 107 scoped_ptr<PrioritizingTaskQueueSelector> task_queue_selector_; |
108 scoped_ptr<TaskQueueManager> task_queue_manager_; | 108 scoped_ptr<TaskQueueManager> task_queue_manager_; |
109 | 109 |
110 uint64 quiescence_monitored_task_queue_mask_; | 110 uint64 quiescence_monitored_task_queue_mask_; |
111 | 111 |
112 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | 112 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
113 scoped_refptr<base::SingleThreadTaskRunner> control_after_wakeup_task_runner_; | 113 scoped_refptr<base::SingleThreadTaskRunner> control_after_wakeup_task_runner_; |
114 scoped_refptr<TaskQueue> default_task_runner_; | 114 scoped_refptr<TaskQueue> default_task_runner_; |
115 | 115 |
116 scoped_ptr<base::TickClock> time_source_; | 116 scoped_ptr<base::TickClock> time_source_; |
117 | 117 |
118 const char* tracing_category_; | 118 const char* tracing_category_; |
119 const char* disabled_by_default_tracing_category_; | 119 const char* disabled_by_default_tracing_category_; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); | 121 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); |
122 }; | 122 }; |
123 | 123 |
124 } // namespace scheduler | 124 } // namespace scheduler |
125 | 125 |
126 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ | 126 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ |
OLD | NEW |