| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void OnBeginNestedMessageLoop() override; | 169 void OnBeginNestedMessageLoop() override; |
| 170 | 170 |
| 171 // Called by the task queue to register a new pending task. | 171 // Called by the task queue to register a new pending task. |
| 172 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); | 172 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); |
| 173 | 173 |
| 174 // Use the selector to choose a pending task and run it. | 174 // Use the selector to choose a pending task and run it. |
| 175 void DoWork(base::TimeTicks run_time, bool from_main_thread); | 175 void DoWork(base::TimeTicks run_time, bool from_main_thread); |
| 176 | 176 |
| 177 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and | 177 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and |
| 178 // reloads any empty work queues. | 178 // reloads any empty work queues. |
| 179 void UpdateWorkQueues(LazyNow lazy_now); | 179 void UpdateWorkQueues(LazyNow* lazy_now); |
| 180 | 180 |
| 181 // Chooses the next work queue to service. Returns true if |out_queue| | 181 // 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 | 182 // indicates the queue from which the next task should be run, false to |
| 183 // avoid running any tasks. | 183 // avoid running any tasks. |
| 184 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); | 184 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); |
| 185 | 185 |
| 186 // Runs a single nestable task from the |queue|. On exit, |out_task| will | 186 // 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 | 187 // contain the task which was executed. Non-nestable task are reposted on the |
| 188 // run loop. The queue must not be empty. | 188 // run loop. The queue must not be empty. |
| 189 enum class ProcessTaskResult { | 189 enum class ProcessTaskResult { |
| 190 DEFERRED, | 190 DEFERRED, |
| 191 EXECUTED, | 191 EXECUTED, |
| 192 TASK_QUEUE_MANAGER_DELETED | 192 TASK_QUEUE_MANAGER_DELETED |
| 193 }; | 193 }; |
| 194 ProcessTaskResult ProcessTaskFromWorkQueue(internal::WorkQueue* work_queue, | 194 ProcessTaskResult ProcessTaskFromWorkQueue(internal::WorkQueue* work_queue, |
| 195 LazyNow*); | 195 LazyNow*); |
| 196 | 196 |
| 197 bool RunsTasksOnCurrentThread() const; | 197 bool RunsTasksOnCurrentThread() const; |
| 198 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 198 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 199 const base::Closure& task, | 199 const base::Closure& task, |
| 200 base::TimeDelta delay); | 200 base::TimeDelta delay); |
| 201 | 201 |
| 202 internal::EnqueueOrder GetNextSequenceNumber(); | 202 internal::EnqueueOrder GetNextSequenceNumber(); |
| 203 | 203 |
| 204 // Calls MaybeAdvanceTime on all time domains and returns true if one of them | 204 // Calls DelayTillNextTask on all time domains and returns the smallest delay |
| 205 // was able to advance. | 205 // requested if any. |
| 206 bool TryAdvanceTimeDomains(); | 206 base::Optional<base::TimeDelta> ComputeDelayTillNextTask(LazyNow* lazy_now); |
| 207 | 207 |
| 208 void MaybeRecordTaskDelayHistograms( | 208 void MaybeRecordTaskDelayHistograms( |
| 209 const internal::TaskQueueImpl::Task& pending_task, | 209 const internal::TaskQueueImpl::Task& pending_task, |
| 210 const internal::TaskQueueImpl* queue); | 210 const internal::TaskQueueImpl* queue); |
| 211 | 211 |
| 212 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 212 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 213 AsValueWithSelectorResult(bool should_run, | 213 AsValueWithSelectorResult(bool should_run, |
| 214 internal::WorkQueue* selected_work_queue) const; | 214 internal::WorkQueue* selected_work_queue) const; |
| 215 | 215 |
| 216 std::set<TimeDomain*> time_domains_; | 216 std::set<TimeDomain*> time_domains_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 259 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
| 260 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 260 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
| 261 | 261 |
| 262 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 262 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
| 263 }; | 263 }; |
| 264 | 264 |
| 265 } // namespace scheduler | 265 } // namespace scheduler |
| 266 } // namespace blink | 266 } // namespace blink |
| 267 | 267 |
| 268 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_
H_ | 268 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_
H_ |
| OLD | NEW |