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_TASK_QUEUE_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 // Returns true if any task from a monitored task queue was was run since the | 82 // Returns true if any task from a monitored task queue was was run since the |
83 // last call to GetAndClearSystemIsQuiescentBit. | 83 // last call to GetAndClearSystemIsQuiescentBit. |
84 bool GetAndClearSystemIsQuiescentBit(); | 84 bool GetAndClearSystemIsQuiescentBit(); |
85 | 85 |
86 // Creates a task queue with the given |spec|. Must be called on the thread | 86 // Creates a task queue with the given |spec|. Must be called on the thread |
87 // this class was created on. | 87 // this class was created on. |
88 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( | 88 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( |
89 const TaskQueue::Spec& spec); | 89 const TaskQueue::Spec& spec); |
90 | 90 |
| 91 class SCHEDULER_EXPORT Observer { |
| 92 public: |
| 93 virtual ~Observer() {} |
| 94 |
| 95 // Called when |queue| is unregistered. |
| 96 virtual void OnUnregisterTaskQueue( |
| 97 const scoped_refptr<internal::TaskQueueImpl>& queue) = 0; |
| 98 }; |
| 99 |
| 100 // Called once to set the Observer. This function is called on the main |
| 101 // thread. If |observer| is null, then no callbacks will occur. |
| 102 // Note |observer| is expected to outlive the SchedulerHelper. |
| 103 void SetQueueObserver(Observer* observer); |
| 104 |
91 private: | 105 private: |
92 friend class internal::LazyNow; | 106 friend class internal::LazyNow; |
93 friend class internal::TaskQueueImpl; | 107 friend class internal::TaskQueueImpl; |
94 friend class TaskQueueManagerTest; | 108 friend class TaskQueueManagerTest; |
95 | 109 |
96 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { | 110 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { |
97 private: | 111 private: |
98 friend class base::RefCounted<DeletionSentinel>; | 112 friend class base::RefCounted<DeletionSentinel>; |
99 ~DeletionSentinel() {} | 113 ~DeletionSentinel() {} |
100 }; | 114 }; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 238 |
225 int work_batch_size_; | 239 int work_batch_size_; |
226 | 240 |
227 scoped_ptr<base::TickClock> time_source_; | 241 scoped_ptr<base::TickClock> time_source_; |
228 | 242 |
229 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 243 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
230 | 244 |
231 const char* disabled_by_default_tracing_category_; | 245 const char* disabled_by_default_tracing_category_; |
232 const char* disabled_by_default_verbose_tracing_category_; | 246 const char* disabled_by_default_verbose_tracing_category_; |
233 | 247 |
| 248 Observer* queue_observer_; // NOT OWNED |
234 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 249 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
235 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 250 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
236 | 251 |
237 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 252 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
238 }; | 253 }; |
239 | 254 |
240 } // namespace scheduler | 255 } // namespace scheduler |
241 | 256 |
242 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 257 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
OLD | NEW |