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

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 compile Created 3 years, 10 months 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 919543e9ecf1dc6f65158aa9eb0bd6c4a73e3445..9f8c9090d0af9bdce51e8464aff14a6172545c08 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
@@ -36,6 +36,7 @@ void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
base::TimeTicks now) {
DCHECK(main_thread_checker_.CalledOnValidThread());
DCHECK_EQ(queue->GetTimeDomain(), this);
+ DCHECK(queue->IsQueueEnabled());
// We only want to store a single wakeup per queue, so we need to remove any
// previously registered wake up for |queue|.
if (queue->heap_handle().IsValid()) {
@@ -52,10 +53,8 @@ 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(now, delayed_run_time);
if (observer_)
observer_->OnTimeDomainHasDelayedWork(queue);
@@ -75,9 +74,18 @@ void TimeDomain::CancelDelayedWork(internal::TaskQueueImpl* queue) {
return;
DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks());
+ 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) {
+ CancelWakeupAt(prev_first_wakeup);
+ RequestWakeupAt(Now(), delayed_wakeup_queue_.min().time);
+ }
}
void TimeDomain::WakeupReadyDelayedQueues(LazyNow* lazy_now) {

Powered by Google App Engine
This is Rietveld 408576698