Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_IMPL_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 void ReloadImmediateWorkQueueIfEmpty(); | 170 void ReloadImmediateWorkQueueIfEmpty(); |
| 171 | 171 |
| 172 void AsValueInto(base::trace_event::TracedValue* state) const; | 172 void AsValueInto(base::trace_event::TracedValue* state) const; |
| 173 | 173 |
| 174 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } | 174 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } |
| 175 bool GetShouldNotifyObservers() const { return should_notify_observers_; } | 175 bool GetShouldNotifyObservers() const { return should_notify_observers_; } |
| 176 | 176 |
| 177 void NotifyWillProcessTask(const base::PendingTask& pending_task); | 177 void NotifyWillProcessTask(const base::PendingTask& pending_task); |
| 178 void NotifyDidProcessTask(const base::PendingTask& pending_task); | 178 void NotifyDidProcessTask(const base::PendingTask& pending_task); |
| 179 | 179 |
| 180 void SetScheduledTimeDomainWakeUp( | |
| 181 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up); | |
| 182 | |
| 183 // Check for pending immediate work, but do not look in | |
| 184 // delayed_incoming_queue. | |
| 185 // Used check if we need to generate notifications about delayed work. | |
|
Sami
2017/04/10 17:45:07
"Used to check"?
altimin
2017/05/08 15:40:12
Done.
| |
| 186 bool HasPendingImmediateWorkWithoutDelayedIncomingQueue(); | |
|
Sami
2017/04/10 17:45:07
This name is pretty hard to parse. HasPendingNonDe
altimin
2017/05/08 15:40:12
HasPendingImmediateWork -> HasTasksToRunImmediatel
| |
| 187 | |
| 180 WorkQueue* delayed_work_queue() { | 188 WorkQueue* delayed_work_queue() { |
| 181 return main_thread_only().delayed_work_queue.get(); | 189 return main_thread_only().delayed_work_queue.get(); |
| 182 } | 190 } |
| 183 | 191 |
| 184 const WorkQueue* delayed_work_queue() const { | 192 const WorkQueue* delayed_work_queue() const { |
| 185 return main_thread_only().delayed_work_queue.get(); | 193 return main_thread_only().delayed_work_queue.get(); |
| 186 } | 194 } |
| 187 | 195 |
| 188 WorkQueue* immediate_work_queue() { | 196 WorkQueue* immediate_work_queue() { |
| 189 return main_thread_only().immediate_work_queue.get(); | 197 return main_thread_only().immediate_work_queue.get(); |
| 190 } | 198 } |
| 191 | 199 |
| 192 const WorkQueue* immediate_work_queue() const { | 200 const WorkQueue* immediate_work_queue() const { |
| 193 return main_thread_only().immediate_work_queue.get(); | 201 return main_thread_only().immediate_work_queue.get(); |
| 194 } | 202 } |
| 195 | 203 |
| 196 bool should_report_when_execution_blocked() const { | 204 bool should_report_when_execution_blocked() const { |
| 197 return should_report_when_execution_blocked_; | 205 return should_report_when_execution_blocked_; |
| 198 } | 206 } |
| 199 | 207 |
| 200 // Enqueues any delayed tasks which should be run now on the | 208 // Enqueues any delayed tasks which should be run now on the |
| 201 // |delayed_work_queue|. Returns the subsequent wake-up that is required, if | 209 // |delayed_work_queue|. Returns the subsequent wake-up that is required, if |
| 202 // any. Must be called from the main thread. | 210 // any. Must be called from the main thread. |
| 203 base::Optional<DelayedWakeUp> WakeUpForDelayedWork(LazyNow* lazy_now); | 211 base::Optional<DelayedWakeUp> WakeUpForDelayedWork(LazyNow* lazy_now); |
| 204 | 212 |
| 205 base::TimeTicks scheduled_time_domain_wake_up() const { | 213 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up() const { |
| 206 return main_thread_only().scheduled_time_domain_wake_up; | 214 return main_thread_only().scheduled_time_domain_wake_up; |
| 207 } | 215 } |
| 208 | 216 |
| 209 void set_scheduled_time_domain_wake_up( | |
| 210 base::TimeTicks scheduled_time_domain_wake_up) { | |
| 211 main_thread_only().scheduled_time_domain_wake_up = | |
| 212 scheduled_time_domain_wake_up; | |
| 213 } | |
| 214 | |
| 215 HeapHandle heap_handle() const { return main_thread_only().heap_handle; } | 217 HeapHandle heap_handle() const { return main_thread_only().heap_handle; } |
| 216 | 218 |
| 217 void set_heap_handle(HeapHandle heap_handle) { | 219 void set_heap_handle(HeapHandle heap_handle) { |
| 218 main_thread_only().heap_handle = heap_handle; | 220 main_thread_only().heap_handle = heap_handle; |
| 219 } | 221 } |
| 220 | 222 |
| 221 void PushImmediateIncomingTaskForTest(TaskQueueImpl::Task&& task); | 223 void PushImmediateIncomingTaskForTest(TaskQueueImpl::Task&& task); |
| 222 EnqueueOrder GetFenceForTest() const; | 224 EnqueueOrder GetFenceForTest() const; |
| 223 | 225 |
| 224 class QueueEnabledVoterImpl : public QueueEnabledVoter { | 226 class QueueEnabledVoterImpl : public QueueEnabledVoter { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 std::unique_ptr<WorkQueue> delayed_work_queue; | 280 std::unique_ptr<WorkQueue> delayed_work_queue; |
| 279 std::unique_ptr<WorkQueue> immediate_work_queue; | 281 std::unique_ptr<WorkQueue> immediate_work_queue; |
| 280 std::priority_queue<Task> delayed_incoming_queue; | 282 std::priority_queue<Task> delayed_incoming_queue; |
| 281 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; | 283 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; |
| 282 size_t set_index; | 284 size_t set_index; |
| 283 HeapHandle heap_handle; | 285 HeapHandle heap_handle; |
| 284 int is_enabled_refcount; | 286 int is_enabled_refcount; |
| 285 int voter_refcount; | 287 int voter_refcount; |
| 286 base::trace_event::BlameContext* blame_context; // Not owned. | 288 base::trace_event::BlameContext* blame_context; // Not owned. |
| 287 EnqueueOrder current_fence; | 289 EnqueueOrder current_fence; |
| 288 base::TimeTicks scheduled_time_domain_wake_up; | 290 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up; |
| 289 }; | 291 }; |
| 290 | 292 |
| 291 ~TaskQueueImpl() override; | 293 ~TaskQueueImpl() override; |
| 292 | 294 |
| 293 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, | 295 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, |
| 294 base::OnceClosure task, | 296 base::OnceClosure task, |
| 295 TaskType task_type); | 297 TaskType task_type); |
| 296 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, | 298 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, |
| 297 base::OnceClosure task, | 299 base::OnceClosure task, |
| 298 base::TimeDelta delay, | 300 base::TimeDelta delay, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 static void TaskAsValueInto(const Task& task, | 335 static void TaskAsValueInto(const Task& task, |
| 334 base::trace_event::TracedValue* state); | 336 base::trace_event::TracedValue* state); |
| 335 | 337 |
| 336 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); | 338 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); |
| 337 void OnQueueEnabledVoteChanged(bool enabled); | 339 void OnQueueEnabledVoteChanged(bool enabled); |
| 338 void EnableOrDisableWithSelector(bool enable); | 340 void EnableOrDisableWithSelector(bool enable); |
| 339 | 341 |
| 340 // Schedules delayed work on time domain and calls the observer. | 342 // Schedules delayed work on time domain and calls the observer. |
| 341 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now); | 343 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now); |
| 342 | 344 |
| 343 void NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up); | |
| 344 | |
| 345 const base::PlatformThreadId thread_id_; | 345 const base::PlatformThreadId thread_id_; |
| 346 | 346 |
| 347 mutable base::Lock any_thread_lock_; | 347 mutable base::Lock any_thread_lock_; |
| 348 AnyThread any_thread_; | 348 AnyThread any_thread_; |
| 349 struct AnyThread& any_thread() { | 349 struct AnyThread& any_thread() { |
| 350 any_thread_lock_.AssertAcquired(); | 350 any_thread_lock_.AssertAcquired(); |
| 351 return any_thread_; | 351 return any_thread_; |
| 352 } | 352 } |
| 353 const struct AnyThread& any_thread() const { | 353 const struct AnyThread& any_thread() const { |
| 354 any_thread_lock_.AssertAcquired(); | 354 any_thread_lock_.AssertAcquired(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 const bool should_report_when_execution_blocked_; | 387 const bool should_report_when_execution_blocked_; |
| 388 | 388 |
| 389 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 389 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 } // namespace internal | 392 } // namespace internal |
| 393 } // namespace scheduler | 393 } // namespace scheduler |
| 394 } // namespace blink | 394 } // namespace blink |
| 395 | 395 |
| 396 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 396 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |