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

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

Issue 2674903003: Revert of Dont post delayed DoWork for disabled queues. (Closed)
Patch Set: 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 11b562b83f67ba7ff37f9f92c2d3bf22e534e3df..919543e9ecf1dc6f65158aa9eb0bd6c4a73e3445 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
@@ -33,7 +33,7 @@
void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
base::TimeTicks delayed_run_time,
- LazyNow* lazy_now) {
+ base::TimeTicks now) {
DCHECK(main_thread_checker_.CalledOnValidThread());
DCHECK_EQ(queue->GetTimeDomain(), this);
// We only want to store a single wakeup per queue, so we need to remove any
@@ -52,8 +52,10 @@
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);
@@ -73,19 +75,9 @@
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) {
- LazyNow lazy_now = CreateLazyNow();
- CancelWakeupAt(prev_first_wakeup);
- RequestWakeupAt(&lazy_now, delayed_wakeup_queue_.min().time);
- }
}
void TimeDomain::WakeupReadyDelayedQueues(LazyNow* lazy_now) {

Powered by Google App Engine
This is Rietveld 408576698