Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| index 6333a681ebb1329cbce7225c37c9b2325e2d1d28..75b161a27b060b143d9cb36ddc4adf8e60c78692 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| @@ -402,7 +402,7 @@ size_t TaskQueueImpl::GetNumberOfPendingTasks() const { |
| return task_count; |
| } |
| -bool TaskQueueImpl::HasPendingImmediateWork() const { |
| +bool TaskQueueImpl::HasTaskToRunImmediately() const { |
| // Any work queue tasks count as immediate work. |
| if (!main_thread_only().delayed_work_queue->Empty() || |
| !main_thread_only().immediate_work_queue->Empty()) { |
| @@ -821,8 +821,11 @@ void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) { |
| return; |
| if (enable) { |
| - if (HasPendingImmediateWork()) |
| - NotifyWakeUpChangedOnMainThread(base::TimeTicks()); |
| + if (HasPendingImmediateWork() && main_thread_only().observer) { |
| + // Delayed work notification will be issued via time domain. |
| + main_thread_only().observer->OnQueueNextWakeUpChanged(this, |
| + base::TimeTicks()); |
| + } |
| ScheduleDelayedWorkInTimeDomain(main_thread_only().time_domain->Now()); |
| @@ -899,14 +902,36 @@ void TaskQueueImpl::ScheduleDelayedWorkInTimeDomain(base::TimeTicks now) { |
| main_thread_only().time_domain->ScheduleDelayedWork( |
| this, main_thread_only().delayed_incoming_queue.top().delayed_wake_up(), |
| now); |
| +} |
| + |
| +void TaskQueueImpl::SetScheduledTimeDomainWakeUp( |
| + base::Optional<base::TimeTicks> scheduled_time_domain_wake_up) { |
| + main_thread_only().scheduled_time_domain_wake_up = |
| + scheduled_time_domain_wake_up; |
| + |
| + if (!scheduled_time_domain_wake_up) |
|
alex clarke (OOO till 29th)
2017/05/09 12:50:50
nit: Stylistically we tend to collapse all these o
altimin
2017/05/09 13:15:03
I think that in this case the conditions are diffe
alex clarke (OOO till 29th)
2017/05/09 19:18:42
One of the style guide rules is to be consistent w
altimin
2017/05/10 10:42:25
Done.
|
| + return; |
| + if (!main_thread_only().observer) |
| + return; |
| + // If queue has immediate work an appropriate notification has already |
| + // been issued. |
| + if (HasPendingImmediateWork()) |
| + return; |
| - NotifyWakeUpChangedOnMainThread( |
|
alex clarke (OOO till 29th)
2017/05/09 12:50:50
For my education, was this a bug since it looks li
altimin
2017/05/09 13:15:04
Yes, but strictly speaking this wasn't a real bug
|
| - main_thread_only().delayed_incoming_queue.top().delayed_run_time); |
| + main_thread_only().observer->OnQueueNextWakeUpChanged( |
| + this, scheduled_time_domain_wake_up.value()); |
| } |
| -void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { |
| - if (main_thread_only().observer) |
| - main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); |
| +bool TaskQueueImpl::HasPendingImmediateWork() { |
| + // Any work queue tasks count as immediate work. |
| + if (!main_thread_only().delayed_work_queue->Empty() || |
| + !main_thread_only().immediate_work_queue->Empty()) { |
| + return true; |
| + } |
| + |
| + // Finally tasks on |immediate_incoming_queue| count as immediate work. |
| + base::AutoLock lock(immediate_incoming_queue_lock_); |
| + return !immediate_incoming_queue().empty(); |
| } |
| } // namespace internal |