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_BASE_TASK_QUEUE_SELECTOR_H_ | 5 #ifndef COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_SELECTOR_H_ |
6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_SELECTOR_H_ | 6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_SELECTOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // on the main thread. If |observer| is null, then no callbacks will occur. | 78 // on the main thread. If |observer| is null, then no callbacks will occur. |
79 void SetTaskQueueSelectorObserver(Observer* observer); | 79 void SetTaskQueueSelectorObserver(Observer* observer); |
80 | 80 |
81 // Returns true if all the enabled work queues are empty. Returns false | 81 // Returns true if all the enabled work queues are empty. Returns false |
82 // otherwise. | 82 // otherwise. |
83 bool EnabledWorkQueuesEmpty() const; | 83 bool EnabledWorkQueuesEmpty() const; |
84 | 84 |
85 protected: | 85 protected: |
86 class SCHEDULER_EXPORT PrioritizingSelector { | 86 class SCHEDULER_EXPORT PrioritizingSelector { |
87 public: | 87 public: |
88 PrioritizingSelector(TaskQueueSelector* task_queue_selector); | 88 PrioritizingSelector(TaskQueueSelector* task_queue_selector, |
| 89 const char* name); |
89 | 90 |
90 void AssignQueueToSet(internal::TaskQueueImpl* queue, | 91 void ChangeSetIndex(internal::TaskQueueImpl* queue, |
91 TaskQueue::QueuePriority priority); | 92 TaskQueue::QueuePriority priority); |
| 93 void AddQueue(internal::TaskQueueImpl* queue, |
| 94 TaskQueue::QueuePriority priority); |
92 void RemoveQueue(internal::TaskQueueImpl* queue); | 95 void RemoveQueue(internal::TaskQueueImpl* queue); |
93 | 96 |
94 bool SelectWorkQueueToService(TaskQueue::QueuePriority max_priority, | 97 bool SelectWorkQueueToService(TaskQueue::QueuePriority max_priority, |
95 WorkQueue** out_work_queue, | 98 WorkQueue** out_work_queue, |
96 bool* out_chose_delayed_over_immediate); | 99 bool* out_chose_delayed_over_immediate); |
97 | 100 |
98 WorkQueueSets* delayed_work_queue_sets() { | 101 WorkQueueSets* delayed_work_queue_sets() { |
99 return &delayed_work_queue_sets_; | 102 return &delayed_work_queue_sets_; |
100 } | 103 } |
101 WorkQueueSets* immediate_work_queue_sets() { | 104 WorkQueueSets* immediate_work_queue_sets() { |
102 return &immediate_work_queue_sets_; | 105 return &immediate_work_queue_sets_; |
103 } | 106 } |
104 | 107 |
105 const WorkQueueSets* delayed_work_queue_sets() const { | 108 const WorkQueueSets* delayed_work_queue_sets() const { |
106 return &delayed_work_queue_sets_; | 109 return &delayed_work_queue_sets_; |
107 } | 110 } |
108 const WorkQueueSets* immediate_work_queue_sets() const { | 111 const WorkQueueSets* immediate_work_queue_sets() const { |
109 return &immediate_work_queue_sets_; | 112 return &immediate_work_queue_sets_; |
110 } | 113 } |
111 | 114 |
112 bool ChooseOldestWithPriority(TaskQueue::QueuePriority priority, | 115 bool ChooseOldestWithPriority(TaskQueue::QueuePriority priority, |
113 bool* out_chose_delayed_over_immediate, | 116 bool* out_chose_delayed_over_immediate, |
114 WorkQueue** out_work_queue) const; | 117 WorkQueue** out_work_queue) const; |
115 | 118 |
| 119 #if DCHECK_IS_ON() || !defined(NDEBUG) |
| 120 bool CheckContainsQueueForTest(const internal::TaskQueueImpl* queue) const; |
| 121 #endif |
| 122 |
116 private: | 123 private: |
117 bool ChooseOldestImmediateTaskWithPriority( | 124 bool ChooseOldestImmediateTaskWithPriority( |
118 TaskQueue::QueuePriority priority, | 125 TaskQueue::QueuePriority priority, |
119 WorkQueue** out_work_queue) const; | 126 WorkQueue** out_work_queue) const; |
120 | 127 |
121 bool ChooseOldestDelayedTaskWithPriority(TaskQueue::QueuePriority priority, | 128 bool ChooseOldestDelayedTaskWithPriority(TaskQueue::QueuePriority priority, |
122 WorkQueue** out_work_queue) const; | 129 WorkQueue** out_work_queue) const; |
123 | 130 |
124 // Return true if |out_queue| contains the queue with the oldest pending | 131 // Return true if |out_queue| contains the queue with the oldest pending |
125 // task from the set of queues of |priority|, or false if all queues of that | 132 // task from the set of queues of |priority|, or false if all queues of that |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 size_t num_blocked_queues_to_report_; | 197 size_t num_blocked_queues_to_report_; |
191 | 198 |
192 Observer* task_queue_selector_observer_; // NOT OWNED | 199 Observer* task_queue_selector_observer_; // NOT OWNED |
193 DISALLOW_COPY_AND_ASSIGN(TaskQueueSelector); | 200 DISALLOW_COPY_AND_ASSIGN(TaskQueueSelector); |
194 }; | 201 }; |
195 | 202 |
196 } // namespace internal | 203 } // namespace internal |
197 } // namespace scheduler | 204 } // namespace scheduler |
198 | 205 |
199 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_SELECTOR_H | 206 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_SELECTOR_H |
OLD | NEW |