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