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_BASE_TASK_QUEUE_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 // Called once to set the Observer. This function is called on the main | 94 // Called once to set the Observer. This function is called on the main |
95 // thread. If |observer| is null, then no callbacks will occur. | 95 // thread. If |observer| is null, then no callbacks will occur. |
96 // Note |observer| is expected to outlive the SchedulerHelper. | 96 // Note |observer| is expected to outlive the SchedulerHelper. |
97 void SetObserver(Observer* observer); | 97 void SetObserver(Observer* observer); |
98 | 98 |
99 // Returns the delegate used by the TaskQueueManager. | 99 // Returns the delegate used by the TaskQueueManager. |
100 const scoped_refptr<TaskQueueManagerDelegate>& delegate() const; | 100 const scoped_refptr<TaskQueueManagerDelegate>& delegate() const; |
101 | 101 |
102 // Time domains must be registered for the task queues to get updated. | 102 // Time domains must be registered for the task queues to get updated. |
103 void RegisterTimeDomain(TimeDomain* time_domain); | 103 void RegisterTimeDomain(const scoped_refptr<TimeDomain>& time_domain); |
104 void UnregisterTimeDomain(TimeDomain* time_domain); | 104 void UnregisterTimeDomain(const scoped_refptr<TimeDomain>& time_domain); |
105 | 105 |
106 RealTimeDomain* real_time_domain() const { return real_time_domain_.get(); } | 106 const scoped_refptr<RealTimeDomain>& real_time_domain() const { |
| 107 return real_time_domain_; |
| 108 } |
107 | 109 |
108 private: | 110 private: |
109 friend class LazyNow; | 111 friend class LazyNow; |
110 friend class internal::TaskQueueImpl; | 112 friend class internal::TaskQueueImpl; |
111 friend class TaskQueueManagerTest; | 113 friend class TaskQueueManagerTest; |
112 | 114 |
113 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { | 115 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { |
114 private: | 116 private: |
115 friend class base::RefCounted<DeletionSentinel>; | 117 friend class base::RefCounted<DeletionSentinel>; |
116 ~DeletionSentinel() {} | 118 ~DeletionSentinel() {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 base::TimeDelta delay); | 169 base::TimeDelta delay); |
168 | 170 |
169 int GetNextSequenceNumber(); | 171 int GetNextSequenceNumber(); |
170 | 172 |
171 bool TryAdvanceTimeDomains(); | 173 bool TryAdvanceTimeDomains(); |
172 | 174 |
173 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 175 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
174 AsValueWithSelectorResult(bool should_run, | 176 AsValueWithSelectorResult(bool should_run, |
175 internal::TaskQueueImpl* selected_queue) const; | 177 internal::TaskQueueImpl* selected_queue) const; |
176 | 178 |
177 std::set<TimeDomain*> time_domains_; | 179 std::set<scoped_refptr<TimeDomain>> time_domains_; |
178 scoped_ptr<RealTimeDomain> real_time_domain_; | 180 scoped_refptr<RealTimeDomain> real_time_domain_; |
179 | 181 |
180 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_; | 182 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_; |
181 | 183 |
182 // We have to be careful when deleting a queue because some of the code uses | 184 // We have to be careful when deleting a queue because some of the code uses |
183 // raw pointers and doesn't expect the rug to be pulled out from underneath. | 185 // raw pointers and doesn't expect the rug to be pulled out from underneath. |
184 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_; | 186 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_; |
185 | 187 |
186 | 188 |
187 base::AtomicSequenceNumber task_sequence_num_; | 189 base::AtomicSequenceNumber task_sequence_num_; |
188 base::debug::TaskAnnotator task_annotator_; | 190 base::debug::TaskAnnotator task_annotator_; |
(...skipping 14 matching lines...) Expand all Loading... |
203 int work_batch_size_; | 205 int work_batch_size_; |
204 | 206 |
205 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 207 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
206 | 208 |
207 const char* tracing_category_; | 209 const char* tracing_category_; |
208 const char* disabled_by_default_tracing_category_; | 210 const char* disabled_by_default_tracing_category_; |
209 const char* disabled_by_default_verbose_tracing_category_; | 211 const char* disabled_by_default_verbose_tracing_category_; |
210 | 212 |
211 Observer* observer_; // NOT OWNED | 213 Observer* observer_; // NOT OWNED |
212 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 214 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
| 215 scoped_refptr<TimeDomain> time_domain_; |
213 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 216 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
214 | 217 |
215 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 218 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
216 }; | 219 }; |
217 | 220 |
218 } // namespace scheduler | 221 } // namespace scheduler |
219 | 222 |
220 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 223 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
OLD | NEW |