| 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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // literals). They may not include " chars. | 25 // literals). They may not include " chars. |
| 26 SchedulerHelper( | 26 SchedulerHelper( |
| 27 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, | 27 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, |
| 28 const char* tracing_category, | 28 const char* tracing_category, |
| 29 const char* disabled_by_default_tracing_category, | 29 const char* disabled_by_default_tracing_category, |
| 30 const char* disabled_by_default_verbose_tracing_category, | 30 const char* disabled_by_default_verbose_tracing_category, |
| 31 size_t total_task_queue_count); | 31 size_t total_task_queue_count); |
| 32 ~SchedulerHelper(); | 32 ~SchedulerHelper(); |
| 33 | 33 |
| 34 // Returns the default task runner. | 34 // Returns the default task runner. |
| 35 scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner(); | 35 scoped_refptr<TaskQueue> DefaultTaskRunner(); |
| 36 | 36 |
| 37 // Returns the control task runner. Tasks posted to this runner are executed | 37 // 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 | 38 // with the highest priority. Care must be taken to avoid starvation of other |
| 39 // task queues. | 39 // task queues. |
| 40 scoped_refptr<base::SingleThreadTaskRunner> ControlTaskRunner(); | 40 scoped_refptr<base::SingleThreadTaskRunner> ControlTaskRunner(); |
| 41 | 41 |
| 42 // Returns the control task after wakeup runner. Tasks posted to this runner | 42 // Returns the control task after wakeup runner. Tasks posted to this runner |
| 43 // are executed with the highest priority but do not cause the scheduler to | 43 // are executed with the highest priority but do not cause the scheduler to |
| 44 // wake up. Care must be taken to avoid starvation of other task queues. | 44 // wake up. Care must be taken to avoid starvation of other task queues. |
| 45 scoped_refptr<base::SingleThreadTaskRunner> ControlAfterWakeUpTaskRunner(); | 45 scoped_refptr<base::SingleThreadTaskRunner> ControlAfterWakeUpTaskRunner(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 static const char* TaskQueueIdToString(QueueId queue_id); | 71 static const char* TaskQueueIdToString(QueueId queue_id); |
| 72 | 72 |
| 73 void CheckOnValidThread() const { | 73 void CheckOnValidThread() const { |
| 74 DCHECK(thread_checker_.CalledOnValidThread()); | 74 DCHECK(thread_checker_.CalledOnValidThread()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Accessor methods. | 77 // Accessor methods. |
| 78 base::TimeTicks Now() const; | 78 base::TimeTicks Now() const; |
| 79 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( | 79 scoped_refptr<TaskQueue> TaskRunnerForQueue(size_t queue_index) const; |
| 80 size_t queue_index) const; | |
| 81 base::TimeTicks NextPendingDelayedTaskRunTime() const; | 80 base::TimeTicks NextPendingDelayedTaskRunTime() const; |
| 82 void SetQueueName(size_t queue_index, const char* name); | 81 void SetQueueName(size_t queue_index, const char* name); |
| 83 bool IsQueueEmpty(size_t queue_index) const; | 82 bool IsQueueEmpty(size_t queue_index) const; |
| 84 TaskQueueManager::QueueState GetQueueState(size_t queue_index) const; | 83 TaskQueueManager::QueueState GetQueueState(size_t queue_index) const; |
| 85 void SetQueuePriority(size_t queue_index, | 84 void SetQueuePriority(size_t queue_index, |
| 86 PrioritizingTaskQueueSelector::QueuePriority priority); | 85 PrioritizingTaskQueueSelector::QueuePriority priority); |
| 87 void EnableQueue(size_t queue_index, | 86 void EnableQueue(size_t queue_index, |
| 88 PrioritizingTaskQueueSelector::QueuePriority priority); | 87 PrioritizingTaskQueueSelector::QueuePriority priority); |
| 89 void DisableQueue(size_t queue_index); | 88 void DisableQueue(size_t queue_index); |
| 90 bool IsQueueEnabled(size_t queue_index) const; | 89 bool IsQueueEnabled(size_t queue_index) const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 105 friend class SchedulerHelperTest; | 104 friend class SchedulerHelperTest; |
| 106 | 105 |
| 107 base::ThreadChecker thread_checker_; | 106 base::ThreadChecker thread_checker_; |
| 108 scoped_ptr<PrioritizingTaskQueueSelector> task_queue_selector_; | 107 scoped_ptr<PrioritizingTaskQueueSelector> task_queue_selector_; |
| 109 scoped_ptr<TaskQueueManager> task_queue_manager_; | 108 scoped_ptr<TaskQueueManager> task_queue_manager_; |
| 110 | 109 |
| 111 uint64 quiescence_monitored_task_queue_mask_; | 110 uint64 quiescence_monitored_task_queue_mask_; |
| 112 | 111 |
| 113 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | 112 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
| 114 scoped_refptr<base::SingleThreadTaskRunner> control_after_wakeup_task_runner_; | 113 scoped_refptr<base::SingleThreadTaskRunner> control_after_wakeup_task_runner_; |
| 115 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; | 114 scoped_refptr<TaskQueue> default_task_runner_; |
| 116 | 115 |
| 117 scoped_ptr<base::TickClock> time_source_; | 116 scoped_ptr<base::TickClock> time_source_; |
| 118 | 117 |
| 119 const char* tracing_category_; | 118 const char* tracing_category_; |
| 120 const char* disabled_by_default_tracing_category_; | 119 const char* disabled_by_default_tracing_category_; |
| 121 | 120 |
| 122 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); | 121 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 } // namespace scheduler | 124 } // namespace scheduler |
| 126 | 125 |
| 127 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ | 126 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ |
| OLD | NEW |