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

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

Issue 2572893002: [Reland] Dont post delayed DoWork for disabled queues. (Closed)
Patch Set: Fix perftest 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 d3263180a0c340c4a8f77a29a146d0ee67247fa5..a64a34ebc4d01ef423dbd0e2747e842a6926085b 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 @@ void TimeDomain::MigrateQueue(internal::TaskQueueImpl* queue,
// O(log n)
delayed_wakeup_queue_.erase(queue->heap_handle());
- base::TimeTicks destination_now = destination_time_domain->Now();
+ LazyNow destination_lazy_now = destination_time_domain->CreateLazyNow();
destination_time_domain->ScheduleDelayedWork(queue, wake_up_time,
- destination_now);
+ &destination_lazy_now);
}
void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
base::TimeTicks delayed_run_time,
- base::TimeTicks now) {
+ LazyNow* lazy_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,15 +79,31 @@ void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
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) {
- base::TimeDelta delay = std::max(base::TimeDelta(), delayed_run_time - now);
- RequestWakeup(now, delay);
- }
+ if (delayed_wakeup_queue_.min().queue == queue)
+ RequestWakeupAt(lazy_now, delayed_run_time);
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();
+ RequestWakeupAt(&lazy_now, delayed_wakeup_queue_.min().time);
+ }
+}
+
void TimeDomain::OnQueueHasImmediateWork(internal::TaskQueueImpl* queue) {
if (observer_)
observer_->OnTimeDomainHasImmediateWork(queue);

Powered by Google App Engine
This is Rietveld 408576698