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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void OnTaskQueueEnabled(internal::TaskQueueImpl* queue) override; | 162 void OnTaskQueueEnabled(internal::TaskQueueImpl* queue) override; |
163 void OnTriedToSelectBlockedWorkQueue( | 163 void OnTriedToSelectBlockedWorkQueue( |
164 internal::WorkQueue* work_queue) override; | 164 internal::WorkQueue* work_queue) override; |
165 | 165 |
166 // Called by the task queue to register a new pending task. | 166 // Called by the task queue to register a new pending task. |
167 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); | 167 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); |
168 | 168 |
169 // Use the selector to choose a pending task and run it. | 169 // Use the selector to choose a pending task and run it. |
170 void DoWork(base::TimeTicks run_time, bool from_main_thread); | 170 void DoWork(base::TimeTicks run_time, bool from_main_thread); |
171 | 171 |
172 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue. | 172 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and |
173 // Reloads any empty work queues which have automatic pumping enabled and | 173 // reloads any empty work queues. |
174 // which are eligible to be auto pumped based on the |previous_task| which was | 174 void UpdateWorkQueues(LazyNow lazy_now); |
175 // run and |should_trigger_wakeup|. Call with an empty |previous_task| if no | |
176 // task was just run. | |
177 void UpdateWorkQueues(bool should_trigger_wakeup, | |
178 const internal::TaskQueueImpl::Task* previous_task, | |
179 LazyNow lazy_now); | |
180 | 175 |
181 // Chooses the next work queue to service. Returns true if |out_queue| | 176 // Chooses the next work queue to service. Returns true if |out_queue| |
182 // indicates the queue from which the next task should be run, false to | 177 // indicates the queue from which the next task should be run, false to |
183 // avoid running any tasks. | 178 // avoid running any tasks. |
184 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); | 179 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); |
185 | 180 |
186 // Runs a single nestable task from the |queue|. On exit, |out_task| will | 181 // Runs a single nestable task from the |queue|. On exit, |out_task| will |
187 // contain the task which was executed. Non-nestable task are reposted on the | 182 // contain the task which was executed. Non-nestable task are reposted on the |
188 // run loop. The queue must not be empty. | 183 // run loop. The queue must not be empty. |
189 enum class ProcessTaskResult { | 184 enum class ProcessTaskResult { |
190 DEFERRED, | 185 DEFERRED, |
191 EXECUTED, | 186 EXECUTED, |
192 TASK_QUEUE_MANAGER_DELETED | 187 TASK_QUEUE_MANAGER_DELETED |
193 }; | 188 }; |
194 ProcessTaskResult ProcessTaskFromWorkQueue( | 189 ProcessTaskResult ProcessTaskFromWorkQueue(internal::WorkQueue* work_queue); |
195 internal::WorkQueue* work_queue, | |
196 internal::TaskQueueImpl::Task* out_previous_task); | |
197 | 190 |
198 bool RunsTasksOnCurrentThread() const; | 191 bool RunsTasksOnCurrentThread() const; |
199 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 192 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
200 const base::Closure& task, | 193 const base::Closure& task, |
201 base::TimeDelta delay); | 194 base::TimeDelta delay); |
202 | 195 |
203 internal::EnqueueOrder GetNextSequenceNumber(); | 196 internal::EnqueueOrder GetNextSequenceNumber(); |
204 | 197 |
205 // Calls MaybeAdvanceTime on all time domains and returns true if one of them | 198 // Calls MaybeAdvanceTime on all time domains and returns true if one of them |
206 // was able to advance. | 199 // was able to advance. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 253 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 254 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
262 | 255 |
263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 256 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
264 }; | 257 }; |
265 | 258 |
266 } // namespace scheduler | 259 } // namespace scheduler |
267 } // namespace blink | 260 } // namespace blink |
268 | 261 |
269 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_
H_ | 262 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_
H_ |
OLD | NEW |