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 457f7186a8d146159e3deb8f47e18dc4100543a8..ef43524a878288d72e4b89a5fdf6ce485fc18e33 100644 |
--- a/cc/scheduler/delay_based_time_source.cc |
+++ b/cc/scheduler/delay_based_time_source.cc |
@@ -234,34 +234,20 @@ base::TimeTicks DelayBasedTimeSource::Now() const { |
// now=37 tick_target=16.667 new_target=50.000 --> |
// tick(), PostDelayedTask(floor(50.000-37)) --> PostDelayedTask(13) |
base::TimeTicks DelayBasedTimeSource::NextTickTarget(base::TimeTicks now) { |
- base::TimeDelta new_interval = next_parameters_.interval; |
- |
- // |interval_offset| is the offset from |now| to the next multiple of |
- // |interval| after |tick_target|, possibly negative if in the past. |
- base::TimeDelta interval_offset = base::TimeDelta::FromInternalValue( |
- (next_parameters_.tick_target - now).ToInternalValue() % |
- new_interval.ToInternalValue()); |
- // If |now| is exactly on the interval (i.e. offset==0), don't adjust. |
- // Otherwise, if |tick_target| was in the past, adjust forward to the next |
- // tick after |now|. |
- if (interval_offset.ToInternalValue() != 0 && |
- next_parameters_.tick_target < now) { |
- interval_offset += new_interval; |
- } |
- |
- base::TimeTicks new_tick_target = now + interval_offset; |
+ base::TimeTicks new_tick_target = now.SnappedToNextTick( |
+ next_parameters_.tick_target, next_parameters_.interval); |
DCHECK(now <= new_tick_target) |
<< "now = " << now.ToInternalValue() |
<< "; new_tick_target = " << new_tick_target.ToInternalValue() |
- << "; new_interval = " << new_interval.InMicroseconds() |
- << "; tick_target = " << next_parameters_.tick_target.ToInternalValue() |
- << "; interval_offset = " << interval_offset.ToInternalValue(); |
+ << "; new_interval = " << next_parameters_.interval.InMicroseconds() |
+ << "; tick_target = " << next_parameters_.tick_target.ToInternalValue(); |
// Avoid double ticks when: |
// 1) Turning off the timer and turning it right back on. |
// 2) Jittery data is passed to SetTimebaseAndInterval(). |
- if (new_tick_target - last_tick_time_ <= new_interval / kDoubleTickDivisor) |
- new_tick_target += new_interval; |
+ if (new_tick_target - last_tick_time_ <= |
+ next_parameters_.interval / kDoubleTickDivisor) |
+ new_tick_target += next_parameters_.interval; |
return new_tick_target; |
} |
@@ -290,7 +276,8 @@ std::string DelayBasedTimeSourceHighRes::TypeString() const { |
return "DelayBasedTimeSourceHighRes"; |
} |
-void DelayBasedTimeSource::AsValueInto(base::debug::TracedValue* state) const { |
+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()); |