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

Unified Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 1424053002: Adds a flag to support "Virtual Time" to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 5 years, 2 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: components/scheduler/renderer/renderer_scheduler_impl.cc
diff --git a/components/scheduler/renderer/renderer_scheduler_impl.cc b/components/scheduler/renderer/renderer_scheduler_impl.cc
index 51015be4f074331d8c7b114d13da895e6365063c..49e6605d32561ee1f27efa31efd6553d9c11597d 100644
--- a/components/scheduler/renderer/renderer_scheduler_impl.cc
+++ b/components/scheduler/renderer/renderer_scheduler_impl.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/debug/stack_trace.h"
+#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "cc/output/begin_frame_args.h"
@@ -28,7 +29,8 @@ const double kShortIdlePeriodDurationPercentile = 50;
}
RendererSchedulerImpl::RendererSchedulerImpl(
- scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner)
+ scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner,
+ TimeSource time_source)
: helper_(main_task_runner,
"renderer.scheduler",
TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
@@ -48,7 +50,8 @@ RendererSchedulerImpl::RendererSchedulerImpl(
base::Bind(&RendererSchedulerImpl::UpdatePolicy,
base::Unretained(this)),
helper_.ControlTaskRunner()),
- main_thread_only_(compositor_task_runner_),
+ time_source_(time_source),
+ main_thread_only_(compositor_task_runner_, helper_.tick_clock()),
policy_may_need_update_(&any_thread_lock_),
weak_factory_(this) {
update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy,
@@ -97,12 +100,16 @@ RendererSchedulerImpl::Policy::Policy()
default_queue_priority(TaskQueue::NORMAL_PRIORITY) {}
RendererSchedulerImpl::MainThreadOnly::MainThreadOnly(
- const scoped_refptr<TaskQueue>& compositor_task_runner)
- : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount,
+ const scoped_refptr<TaskQueue>& compositor_task_runner,
+ base::TickClock* time_source)
+ : loading_task_cost_estimator(time_source,
+ kLoadingTaskEstimationSampleCount,
kLoadingTaskEstimationPercentile),
- timer_task_cost_estimator(kTimerTaskEstimationSampleCount,
+ timer_task_cost_estimator(time_source,
+ kTimerTaskEstimationSampleCount,
kTimerTaskEstimationPercentile),
idle_time_estimator(compositor_task_runner,
+ time_source,
kShortIdlePeriodDurationSampleCount,
kShortIdlePeriodDurationPercentile),
current_use_case(UseCase::NONE),
@@ -956,4 +963,24 @@ void RendererSchedulerImpl::ResetForNavigationLocked() {
UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED);
}
+double RendererSchedulerImpl::currentTime() const {
+ switch (time_source_) {
Sami 2015/10/28 20:00:35 Do we need to make this distinction here? Why not
alex clarke (OOO till 29th) 2015/10/29 18:07:30 As far as I can tell the distinction is important.
+ case TimeSource::NORMAL:
+ return base::Time::Now().ToDoubleT();
+
+ case TimeSource::VIRTUAL:
+ return (helper_.Now() - base::TimeTicks::UnixEpoch()).InSecondsF();
+
+ default:
+ break;
+ }
+ NOTREACHED();
+ return 0;
+}
+
+double RendererSchedulerImpl::monotonicallyIncreasingTime() const {
+ return helper_.Now().ToInternalValue() /
+ static_cast<double>(base::Time::kMicrosecondsPerSecond);
+}
+
} // namespace scheduler

Powered by Google App Engine
This is Rietveld 408576698