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

Unified Diff: cc/scheduler/delay_based_time_source.cc

Issue 2150533004: cc: Send all begin frames using a PostTask. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler_unittest_no_deadline
Patch Set: Created 4 years, 5 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: cc/scheduler/delay_based_time_source.cc
diff --git a/cc/scheduler/delay_based_time_source.cc b/cc/scheduler/delay_based_time_source.cc
index bc2ec5f8744971904b4e21a5da611c2dded424ec..7a59fe70fa6566be6ae9df52bb956ce32cb731ae 100644
--- a/cc/scheduler/delay_based_time_source.cc
+++ b/cc/scheduler/delay_based_time_source.cc
@@ -21,14 +21,16 @@ namespace cc {
// The following methods correspond to the DelayBasedTimeSource that uses
// the base::TimeTicks::Now as the timebase.
DelayBasedTimeSource::DelayBasedTimeSource(
- base::SingleThreadTaskRunner* task_runner)
- : client_(nullptr),
+ base::SingleThreadTaskRunner* task_runner,
+ base::TickClock* clock)
+ : task_runner_(task_runner),
+ clock_(clock),
+ client_(nullptr),
active_(false),
timebase_(base::TimeTicks()),
interval_(BeginFrameArgs::DefaultInterval()),
last_tick_time_(base::TimeTicks() - interval_),
next_tick_time_(base::TimeTicks()),
- task_runner_(task_runner),
weak_factory_(this) {}
DelayBasedTimeSource::~DelayBasedTimeSource() {}
@@ -54,7 +56,13 @@ base::TimeDelta DelayBasedTimeSource::Interval() const {
return interval_;
}
-bool DelayBasedTimeSource::Active() const { return active_; }
+base::TimeTicks DelayBasedTimeSource::Now() {
+ return clock_ ? clock_->NowTicks() : base::TimeTicks::Now();
brianderson 2016/07/13 21:14:49 DefaultTickClock?
+}
+
+bool DelayBasedTimeSource::Active() const {
+ return active_;
+}
base::TimeTicks DelayBasedTimeSource::LastTickTime() const {
return last_tick_time_;
@@ -86,10 +94,6 @@ void DelayBasedTimeSource::SetTimebaseAndInterval(base::TimeTicks timebase,
timebase_ = timebase;
}
-base::TimeTicks DelayBasedTimeSource::Now() const {
- return base::TimeTicks::Now();
-}
-
// This code tries to achieve an average tick rate as close to interval_ as
// possible. To do this, it has to deal with a few basic issues:
// 1. PostDelayedTask can delay only at a millisecond granularity. So, 16.666
@@ -159,13 +163,8 @@ void DelayBasedTimeSource::PostNextTickTask(base::TimeTicks now) {
next_tick_time_ - now);
}
-std::string DelayBasedTimeSource::TypeString() const {
- return "DelayBasedTimeSource";
-}
-
void DelayBasedTimeSource::AsValueInto(
base::trace_event::TracedValue* state) const {
- state->SetString("type", TypeString());
state->SetDouble("last_tick_time_us", LastTickTime().ToInternalValue());
state->SetDouble("next_tick_time_us", NextTickTime().ToInternalValue());
state->SetDouble("interval_us", interval_.InMicroseconds());

Powered by Google App Engine
This is Rietveld 408576698