| 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 10 matching lines...) Expand all Loading... |
| 151 | 157 |
| 152 // Chooses the next work queue to service. Returns true if |out_queue_index| | 158 // Chooses the next work queue to service. Returns true if |out_queue_index| |
| 153 // indicates the queue from which the next task should be run, false to | 159 // indicates the queue from which the next task should be run, false to |
| 154 // avoid running any tasks. | 160 // avoid running any tasks. |
| 155 bool SelectWorkQueueToService(size_t* out_queue_index); | 161 bool SelectWorkQueueToService(size_t* out_queue_index); |
| 156 | 162 |
| 157 // Runs a single nestable task from the work queue designated by | 163 // Runs a single nestable task from the work queue designated by |
| 158 // |queue_index|. If |has_previous_task| is true, |previous_task| should | 164 // |queue_index|. If |has_previous_task| is true, |previous_task| should |
| 159 // contain the previous task in this work batch. Non-nestable task are | 165 // contain the previous task in this work batch. Non-nestable task are |
| 160 // reposted on the run loop. The queue must not be empty. | 166 // reposted on the run loop. The queue must not be empty. |
| 161 void ProcessTaskFromWorkQueue(size_t queue_index, | 167 // Returns true if the TaskQueueManager got deleted, and false otherwise. |
| 168 bool ProcessTaskFromWorkQueue(size_t queue_index, |
| 162 bool has_previous_task, | 169 bool has_previous_task, |
| 163 base::PendingTask* previous_task); | 170 base::PendingTask* previous_task); |
| 164 | 171 |
| 165 bool RunsTasksOnCurrentThread() const; | 172 bool RunsTasksOnCurrentThread() const; |
| 166 bool PostDelayedTask(const tracked_objects::Location& from_here, | 173 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 167 const base::Closure& task, | 174 const base::Closure& task, |
| 168 base::TimeDelta delay); | 175 base::TimeDelta delay); |
| 169 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 176 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 170 const base::Closure& task, | 177 const base::Closure& task, |
| 171 base::TimeDelta delay); | 178 base::TimeDelta delay); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 191 int pending_dowork_count_; | 198 int pending_dowork_count_; |
| 192 | 199 |
| 193 int work_batch_size_; | 200 int work_batch_size_; |
| 194 | 201 |
| 195 scoped_refptr<cc::TestNowSource> time_source_; | 202 scoped_refptr<cc::TestNowSource> time_source_; |
| 196 | 203 |
| 197 ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 204 ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
| 198 | 205 |
| 199 const char* disabled_by_default_tracing_category_; | 206 const char* disabled_by_default_tracing_category_; |
| 200 | 207 |
| 208 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
| 201 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 209 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
| 202 | 210 |
| 203 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 211 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
| 204 }; | 212 }; |
| 205 | 213 |
| 206 } // namespace content | 214 } // namespace content |
| 207 | 215 |
| 208 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 216 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
| OLD | NEW |