Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1130)

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/time_domain.cc

Issue 2583333002: Revert of Dont post delayed DoWork for disabled queues. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fd911939ae503ea1576d8647203036b2bc46d4ff..d3263180a0c340c4a8f77a29a146d0ee67247fa5 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
@@ -54,14 +54,14 @@
// O(log n)
delayed_wakeup_queue_.erase(queue->heap_handle());
- LazyNow destination_lazy_now = destination_time_domain->CreateLazyNow();
+ base::TimeTicks destination_now = destination_time_domain->Now();
destination_time_domain->ScheduleDelayedWork(queue, wake_up_time,
- &destination_lazy_now);
+ destination_now);
}
void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
base::TimeTicks delayed_run_time,
- LazyNow* lazy_now) {
+ base::TimeTicks now) {
DCHECK(main_thread_checker_.CalledOnValidThread());
// We only want to store a single wakeup per queue, so we need to remove any
// previously registered wake up for |queue|.
@@ -79,30 +79,13 @@
queue->set_scheduled_time_domain_wakeup(delayed_run_time);
// If |queue| is the first wakeup then request the wakeup.
- if (delayed_wakeup_queue_.min().queue == queue)
- RequestWakeupAt(lazy_now, delayed_run_time);
+ if (delayed_wakeup_queue_.min().queue == queue) {
+ base::TimeDelta delay = std::max(base::TimeDelta(), delayed_run_time - now);
+ RequestWakeup(now, delay);
+ }
if (observer_)
observer_->OnTimeDomainHasDelayedWork(queue);
-}
-
-void TimeDomain::CancelDelayedWork(internal::TaskQueueImpl* queue) {
- if (!queue->heap_handle().IsValid())
- return;
-
- DCHECK(!delayed_wakeup_queue_.empty());
- base::TimeTicks prev_first_wakeup = delayed_wakeup_queue_.min().time;
-
- // O(log n)
- delayed_wakeup_queue_.erase(queue->heap_handle());
-
- if (delayed_wakeup_queue_.empty()) {
- CancelWakeupAt(prev_first_wakeup);
- } else if (prev_first_wakeup != delayed_wakeup_queue_.min().time) {
- LazyNow lazy_now = CreateLazyNow();
- CancelWakeupAt(prev_first_wakeup);
- RequestWakeupAt(&lazy_now, delayed_wakeup_queue_.min().time);
- }
}
void TimeDomain::OnQueueHasImmediateWork(internal::TaskQueueImpl* queue) {

Powered by Google App Engine
This is Rietveld 408576698