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 "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
9 #include "base/debug/task_annotator.h" | 9 #include "base/debug/task_annotator.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // manager executes its tasks on. | 121 // manager executes its tasks on. |
122 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 122 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
123 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 123 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
124 | 124 |
125 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); | 125 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); |
126 | 126 |
127 private: | 127 private: |
128 friend class internal::LazyNow; | 128 friend class internal::LazyNow; |
129 friend class internal::TaskQueue; | 129 friend class internal::TaskQueue; |
130 | 130 |
| 131 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { |
| 132 private: |
| 133 friend class base::RefCounted<DeletionSentinel>; |
| 134 ~DeletionSentinel() {} |
| 135 }; |
| 136 |
131 // Called by the task queue to register a new pending task and allocate a | 137 // Called by the task queue to register a new pending task and allocate a |
132 // sequence number for it. | 138 // sequence number for it. |
133 void DidQueueTask(base::PendingTask* pending_task); | 139 void DidQueueTask(base::PendingTask* pending_task); |
134 | 140 |
135 // Post a task to call DoWork() on the main task runner. Only one pending | 141 // Post a task to call DoWork() on the main task runner. Only one pending |
136 // DoWork is allowed from the main thread, to prevent an explosion of pending | 142 // DoWork is allowed from the main thread, to prevent an explosion of pending |
137 // DoWorks. | 143 // DoWorks. |
138 void MaybePostDoWorkOnMainRunner(); | 144 void MaybePostDoWorkOnMainRunner(); |
139 | 145 |
140 // Use the selector to choose a pending task and run it. | 146 // Use the selector to choose a pending task and run it. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 int pending_dowork_count_; | 197 int pending_dowork_count_; |
192 | 198 |
193 int work_batch_size_; | 199 int work_batch_size_; |
194 | 200 |
195 scoped_refptr<cc::TestNowSource> time_source_; | 201 scoped_refptr<cc::TestNowSource> time_source_; |
196 | 202 |
197 ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 203 ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
198 | 204 |
199 const char* disabled_by_default_tracing_category_; | 205 const char* disabled_by_default_tracing_category_; |
200 | 206 |
| 207 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
201 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 208 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
202 | 209 |
203 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 210 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
204 }; | 211 }; |
205 | 212 |
206 } // namespace content | 213 } // namespace content |
207 | 214 |
208 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 215 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
OLD | NEW |