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

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

Issue 2546423002: [Try # 3] Scheduler refactoring to virtually eliminate redundant DoWorks (Closed)
Patch Set: Few tweaks 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/real_time_domain.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/real_time_domain.cc b/third_party/WebKit/Source/platform/scheduler/base/real_time_domain.cc
index 80f18b998d923b8c4b8eb22719be8c42e99f6da4..8614d7ac849ee2a0b9c9bac0b309e34abef5476e 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/real_time_domain.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/real_time_domain.cc
@@ -46,23 +46,23 @@ void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) {
task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay);
}
-bool RealTimeDomain::MaybeAdvanceTime() {
+base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask(
+ LazyNow* lazy_now) {
base::TimeTicks next_run_time;
if (!NextScheduledRunTime(&next_run_time))
- return false;
+ return base::Optional<base::TimeDelta>();
- base::TimeTicks now = Now();
+ base::TimeTicks now = lazy_now->Now();
if (now >= next_run_time)
- return true; // Causes DoWork to post a continuation.
+ return base::TimeDelta(); // Makes DoWork post an immediate continuation.
base::TimeDelta delay = next_run_time - now;
- TRACE_EVENT1(tracing_category_, "RealTimeDomain::MaybeAdvanceTime",
+ TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask",
"delay_ms", delay.InMillisecondsF());
- // The next task is sometime in the future, make sure we schedule a DoWork to
- // run it.
- task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay);
- return false;
+ // The next task is sometime in the future. DoWork will make sure it gets
+ // run at the right time..
+ return delay;
}
void RealTimeDomain::AsValueIntoInternal(

Powered by Google App Engine
This is Rietveld 408576698