| 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/cancelable_closure_holder.h" | 8 #include "components/scheduler/child/cancelable_closure_holder.h" |
| 9 #include "components/scheduler/child/prioritizing_task_queue_selector.h" |
| 9 #include "components/scheduler/child/single_thread_idle_task_runner.h" | 10 #include "components/scheduler/child/single_thread_idle_task_runner.h" |
| 10 #include "components/scheduler/child/task_queue_manager.h" | 11 #include "components/scheduler/child/task_queue_manager.h" |
| 11 #include "components/scheduler/child/time_source.h" | 12 #include "components/scheduler/child/time_source.h" |
| 12 #include "components/scheduler/scheduler_export.h" | 13 #include "components/scheduler/scheduler_export.h" |
| 13 | 14 |
| 14 namespace scheduler { | 15 namespace scheduler { |
| 15 | 16 |
| 16 class PrioritizingTaskQueueSelector; | |
| 17 class NestableSingleThreadTaskRunner; | 17 class NestableSingleThreadTaskRunner; |
| 18 | 18 |
| 19 // Common scheduler functionality for Default and Idle tasks. | 19 // Common scheduler functionality for Default and Idle tasks. |
| 20 class SCHEDULER_EXPORT SchedulerHelper { | 20 class SCHEDULER_EXPORT SchedulerHelper { |
| 21 public: | 21 public: |
| 22 // Used to by scheduler implementations to customize idle behaviour. | 22 // Used to by scheduler implementations to customize idle behaviour. |
| 23 class SCHEDULER_EXPORT SchedulerHelperDelegate { | 23 class SCHEDULER_EXPORT SchedulerHelperDelegate { |
| 24 public: | 24 public: |
| 25 SchedulerHelperDelegate(); | 25 SchedulerHelperDelegate(); |
| 26 virtual ~SchedulerHelperDelegate(); | 26 virtual ~SchedulerHelperDelegate(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Returns true if |state| represents being within an idle period state. | 152 // Returns true if |state| represents being within an idle period state. |
| 153 static bool IsInIdlePeriod(IdlePeriodState state); | 153 static bool IsInIdlePeriod(IdlePeriodState state); |
| 154 | 154 |
| 155 void CheckOnValidThread() const { | 155 void CheckOnValidThread() const { |
| 156 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Accessor methods. | 159 // Accessor methods. |
| 160 base::TimeTicks Now() const; | 160 base::TimeTicks Now() const; |
| 161 IdlePeriodState SchedulerIdlePeriodState() const; | 161 IdlePeriodState SchedulerIdlePeriodState() const; |
| 162 PrioritizingTaskQueueSelector* SchedulerTaskQueueSelector() const; | |
| 163 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( | 162 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( |
| 164 size_t queue_index) const; | 163 size_t queue_index) const; |
| 165 void SetQueueName(size_t queue_index, const char* name); | 164 void SetQueueName(size_t queue_index, const char* name); |
| 166 bool IsQueueEmpty(size_t queue_index) const; | 165 bool IsQueueEmpty(size_t queue_index) const; |
| 166 void SetQueuePriority(size_t queue_index, |
| 167 PrioritizingTaskQueueSelector::QueuePriority priority); |
| 168 void EnableQueue(size_t queue_index, |
| 169 PrioritizingTaskQueueSelector::QueuePriority priority); |
| 170 void DisableQueue(size_t queue_index); |
| 171 bool IsQueueEnabled(size_t queue_index) const; |
| 167 | 172 |
| 168 // Test helpers. | 173 // Test helpers. |
| 169 void SetTimeSourceForTesting(scoped_ptr<TimeSource> time_source); | 174 void SetTimeSourceForTesting(scoped_ptr<TimeSource> time_source); |
| 170 void SetWorkBatchSizeForTesting(size_t work_batch_size); | 175 void SetWorkBatchSizeForTesting(size_t work_batch_size); |
| 171 TaskQueueManager* GetTaskQueueManagerForTesting(); | 176 TaskQueueManager* GetTaskQueueManagerForTesting(); |
| 172 | 177 |
| 173 private: | 178 private: |
| 174 friend class SchedulerHelperTest; | 179 friend class SchedulerHelperTest; |
| 175 | 180 |
| 176 bool ShouldWaitForQuiescence(); | 181 bool ShouldWaitForQuiescence(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 206 | 211 |
| 207 base::WeakPtr<SchedulerHelper> weak_scheduler_ptr_; | 212 base::WeakPtr<SchedulerHelper> weak_scheduler_ptr_; |
| 208 base::WeakPtrFactory<SchedulerHelper> weak_factory_; | 213 base::WeakPtrFactory<SchedulerHelper> weak_factory_; |
| 209 | 214 |
| 210 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); | 215 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); |
| 211 }; | 216 }; |
| 212 | 217 |
| 213 } // namespace scheduler | 218 } // namespace scheduler |
| 214 | 219 |
| 215 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ | 220 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ |
| OLD | NEW |