| 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 void DidQueueTask(base::PendingTask* pending_task); | 121 void DidQueueTask(base::PendingTask* pending_task); |
| 122 | 122 |
| 123 // Post a task to call DoWork() on the main task runner. Only one pending | 123 // Post a task to call DoWork() on the main task runner. Only one pending |
| 124 // DoWork is allowed from the main thread, to prevent an explosion of pending | 124 // DoWork is allowed from the main thread, to prevent an explosion of pending |
| 125 // DoWorks. | 125 // DoWorks. |
| 126 void MaybePostDoWorkOnMainRunner(); | 126 void MaybePostDoWorkOnMainRunner(); |
| 127 | 127 |
| 128 // Use the selector to choose a pending task and run it. | 128 // Use the selector to choose a pending task and run it. |
| 129 void DoWork(bool posted_from_main_thread); | 129 void DoWork(bool posted_from_main_thread); |
| 130 | 130 |
| 131 // Delayed Tasks with run_times <= |now| are enqueued onto their work queues. |
| 131 // Reloads any empty work queues which have automatic pumping enabled and | 132 // Reloads any empty work queues which have automatic pumping enabled and |
| 132 // which are eligible to be auto pumped based on the |previous_task| which was | 133 // which are eligible to be auto pumped based on the |previous_task| which was |
| 133 // run. Call with an empty |previous_task| if no task was just run. Returns | 134 // run. Call with an empty |previous_task| if no task was just run. Returns |
| 134 // true if any work queue has tasks after doing this. | 135 // true if any work queue has tasks after doing this. |
| 135 // |next_pending_delayed_task| should be the time of the next known delayed | 136 // |next_pending_delayed_task| should be the time of the next known delayed |
| 136 // task. It is updated if any task is found which should run earlier. | 137 // task. It is updated if any task is found which should run earlier. |
| 137 bool UpdateWorkQueues(base::TimeTicks* next_pending_delayed_task, | 138 bool UpdateWorkQueues(base::TimeTicks now, |
| 138 const base::PendingTask* previous_task); | 139 const base::PendingTask* previous_task); |
| 139 | 140 |
| 140 // Chooses the next work queue to service. Returns true if |out_queue_index| | 141 // Chooses the next work queue to service. Returns true if |out_queue_index| |
| 141 // indicates the queue from which the next task should be run, false to | 142 // indicates the queue from which the next task should be run, false to |
| 142 // avoid running any tasks. | 143 // avoid running any tasks. |
| 143 bool SelectWorkQueueToService(size_t* out_queue_index); | 144 bool SelectWorkQueueToService(size_t* out_queue_index); |
| 144 | 145 |
| 145 // Runs a single nestable task from the work queue designated by | 146 // Runs a single nestable task from the work queue designated by |
| 146 // |queue_index|. If |has_previous_task| is true, |previous_task| should | 147 // |queue_index|. If |has_previous_task| is true, |previous_task| should |
| 147 // contain the previous task in this work batch. Non-nestable task are | 148 // contain the previous task in this work batch. Non-nestable task are |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 186 ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
| 186 | 187 |
| 187 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 188 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
| 188 | 189 |
| 189 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 190 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
| 190 }; | 191 }; |
| 191 | 192 |
| 192 } // namespace content | 193 } // namespace content |
| 193 | 194 |
| 194 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 195 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
| OLD | NEW |