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

Unified Diff: cc/scheduler/delay_based_time_source.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/scheduler/delay_based_time_source.h ('k') | cc/scheduler/delay_based_time_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « cc/scheduler/delay_based_time_source.h ('k') | cc/scheduler/delay_based_time_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698