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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 bool PostDelayedTask(const tracked_objects::Location& from_here, | 135 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 136 base::OnceClosure task, | 136 base::OnceClosure task, |
| 137 base::TimeDelta delay) override; | 137 base::TimeDelta delay) override; |
| 138 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 138 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 139 base::OnceClosure task, | 139 base::OnceClosure task, |
| 140 base::TimeDelta delay) override; | 140 base::TimeDelta delay) override; |
| 141 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override; | 141 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override; |
| 142 bool IsQueueEnabled() const override; | 142 bool IsQueueEnabled() const override; |
| 143 bool IsEmpty() const override; | 143 bool IsEmpty() const override; |
| 144 size_t GetNumberOfPendingTasks() const override; | 144 size_t GetNumberOfPendingTasks() const override; |
| 145 bool HasPendingImmediateWork() const override; | 145 bool HasTaskToRunImmediately() const override; |
| 146 base::Optional<base::TimeTicks> GetNextScheduledWakeUp() override; | 146 base::Optional<base::TimeTicks> GetNextScheduledWakeUp() override; |
| 147 void SetQueuePriority(QueuePriority priority) override; | 147 void SetQueuePriority(QueuePriority priority) override; |
| 148 QueuePriority GetQueuePriority() const override; | 148 QueuePriority GetQueuePriority() const override; |
| 149 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; | 149 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
| 150 void RemoveTaskObserver( | 150 void RemoveTaskObserver( |
| 151 base::MessageLoop::TaskObserver* task_observer) override; | 151 base::MessageLoop::TaskObserver* task_observer) override; |
| 152 void SetTimeDomain(TimeDomain* time_domain) override; | 152 void SetTimeDomain(TimeDomain* time_domain) override; |
| 153 TimeDomain* GetTimeDomain() const override; | 153 TimeDomain* GetTimeDomain() const override; |
| 154 void SetBlameContext(base::trace_event::BlameContext* blame_context) override; | 154 void SetBlameContext(base::trace_event::BlameContext* blame_context) override; |
| 155 void InsertFence(InsertFencePosition position) override; | 155 void InsertFence(InsertFencePosition position) override; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 170 | 170 |
| 171 void AsValueInto(base::TimeTicks now, | 171 void AsValueInto(base::TimeTicks now, |
| 172 base::trace_event::TracedValue* state) const; | 172 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( | |
|
alex clarke (OOO till 29th)
2017/05/09 12:50:50
Can you please add a brief comment mentioning that
altimin
2017/05/09 13:15:04
Done.
| |
| 181 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up); | |
|
alex clarke (OOO till 29th)
2017/05/09 12:50:50
Also please document which threads these two calls
altimin
2017/05/09 13:15:04
Done.
| |
| 182 | |
| 183 // Check for pending immediate work, but do not look in | |
|
alex clarke (OOO till 29th)
2017/05/09 11:51:28
s/but do not look in/but does not look in
Also pl
altimin
2017/05/09 13:15:04
Done.
| |
| 184 // delayed_incoming_queue. | |
| 185 // Used to check if we need to generate notifications about delayed work. | |
| 186 bool HasPendingImmediateWork(); | |
| 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 { |
|
alex clarke (OOO till 29th)
2017/05/09 11:51:28
Why do we need to use optional here? What's wrong
altimin
2017/05/09 13:15:04
I prefer explicit base::nullopt to describe "no wa
| |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 base::TimeTicks now, | 342 base::TimeTicks now, |
| 341 base::trace_event::TracedValue* state); | 343 base::trace_event::TracedValue* state); |
| 342 | 344 |
| 343 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); | 345 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); |
| 344 void OnQueueEnabledVoteChanged(bool enabled); | 346 void OnQueueEnabledVoteChanged(bool enabled); |
| 345 void EnableOrDisableWithSelector(bool enable); | 347 void EnableOrDisableWithSelector(bool enable); |
| 346 | 348 |
| 347 // Schedules delayed work on time domain and calls the observer. | 349 // Schedules delayed work on time domain and calls the observer. |
| 348 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now); | 350 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now); |
| 349 | 351 |
| 350 void NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up); | |
| 351 | |
| 352 const base::PlatformThreadId thread_id_; | 352 const base::PlatformThreadId thread_id_; |
| 353 | 353 |
| 354 mutable base::Lock any_thread_lock_; | 354 mutable base::Lock any_thread_lock_; |
| 355 AnyThread any_thread_; | 355 AnyThread any_thread_; |
| 356 struct AnyThread& any_thread() { | 356 struct AnyThread& any_thread() { |
| 357 any_thread_lock_.AssertAcquired(); | 357 any_thread_lock_.AssertAcquired(); |
| 358 return any_thread_; | 358 return any_thread_; |
| 359 } | 359 } |
| 360 const struct AnyThread& any_thread() const { | 360 const struct AnyThread& any_thread() const { |
| 361 any_thread_lock_.AssertAcquired(); | 361 any_thread_lock_.AssertAcquired(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 392 const bool should_report_when_execution_blocked_; | 392 const bool should_report_when_execution_blocked_; |
| 393 | 393 |
| 394 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 394 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 395 }; | 395 }; |
| 396 | 396 |
| 397 } // namespace internal | 397 } // namespace internal |
| 398 } // namespace scheduler | 398 } // namespace scheduler |
| 399 } // namespace blink | 399 } // namespace blink |
| 400 | 400 |
| 401 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 401 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |