Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/time_domain.cc |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc |
| index 539fca26613f800cfae26a7ae72c6d1d62ae273e..0bdaeb3a1887ce3d233f23d5de7a09ce9a97a019 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc |
| @@ -84,6 +84,37 @@ void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue, |
| observer_->OnTimeDomainHasDelayedWork(); |
| } |
| +void TimeDomain::CancelDelayedWork(internal::TaskQueueImpl* queue, |
| + base::TimeTicks delayed_run_time) { |
| + DCHECK(main_thread_checker_.CalledOnValidThread()); |
| + |
| + auto iterpair = delayed_wakeup_multimap_.equal_range(delayed_run_time); |
| + for (auto it = iterpair.first; it != iterpair.second; ++it) { |
| + if (it->second == queue) { |
| + base::TimeTicks prev_first_wakeup = |
| + delayed_wakeup_multimap_.begin()->first; |
| + delayed_wakeup_multimap_.erase(it); |
| + |
| + if (delayed_wakeup_multimap_.empty()) |
| + break; |
| + |
| + base::TimeTicks first_wakeup = delayed_wakeup_multimap_.begin()->first; |
| + |
| + if (first_wakeup == prev_first_wakeup) |
|
haraken
2016/08/19 10:42:51
I'm just curious but what is this check doing?
alex clarke (OOO till 29th)
2016/08/19 11:02:59
I added a comment, it's checking if the first entr
|
| + break; |
| + |
| + // The first wakeup has changed, we need to re-schedule. |
| + base::TimeTicks now = Now(); |
| + base::TimeDelta delay = std::max(base::TimeDelta(), first_wakeup - now); |
| + RequestWakeup(now, delay); |
| + break; |
|
haraken
2016/08/19 10:42:51
This for loop finishes when it encounters the firs
alex clarke (OOO till 29th)
2016/08/19 11:02:59
I added a comment above but there might be other q
|
| + } |
| + } |
| + |
| + // Note since the base TaskRunner does not support cancellation there's no |
| + // point trying to cancel a wakeup requested via RequestWakeup :( |
| +} |
| + |
| void TimeDomain::RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue) { |
| { |
| base::AutoLock lock(newly_updatable_lock_); |