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

Side by Side Diff: cc/scheduler/delay_based_time_source.cc

Issue 16023016: cc: Add info for DCHECK in DBTS::NextTickTarget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/delay_based_time_source.h" 5 #include "cc/scheduler/delay_based_time_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // now=37 tick_target=16.667 new_target=50.000 --> 205 // now=37 tick_target=16.667 new_target=50.000 -->
206 // tick(), PostDelayedTask(floor(50.000-37)) --> PostDelayedTask(13) 206 // tick(), PostDelayedTask(floor(50.000-37)) --> PostDelayedTask(13)
207 base::TimeTicks DelayBasedTimeSource::NextTickTarget(base::TimeTicks now) { 207 base::TimeTicks DelayBasedTimeSource::NextTickTarget(base::TimeTicks now) {
208 base::TimeDelta new_interval = next_parameters_.interval; 208 base::TimeDelta new_interval = next_parameters_.interval;
209 int intervals_elapsed = 209 int intervals_elapsed =
210 static_cast<int>(floor((now - next_parameters_.tick_target).InSecondsF() / 210 static_cast<int>(floor((now - next_parameters_.tick_target).InSecondsF() /
211 new_interval.InSecondsF())); 211 new_interval.InSecondsF()));
212 base::TimeTicks last_effective_tick = 212 base::TimeTicks last_effective_tick =
213 next_parameters_.tick_target + new_interval * intervals_elapsed; 213 next_parameters_.tick_target + new_interval * intervals_elapsed;
214 base::TimeTicks new_tick_target = last_effective_tick + new_interval; 214 base::TimeTicks new_tick_target = last_effective_tick + new_interval;
215 DCHECK(new_tick_target > now); 215 DCHECK(now < new_tick_target)
216 << "now = " << now.ToInternalValue()
217 << "; new_tick_target = " << new_tick_target.ToInternalValue()
218 << "; new_interval = " << new_interval.InMicroseconds()
219 << "; tick_target = " << next_parameters_.tick_target.ToInternalValue()
220 << "; intervals_elapsed = " << intervals_elapsed
221 << "; last_effective_tick = " << last_effective_tick.ToInternalValue();
216 222
217 // Avoid double ticks when: 223 // Avoid double ticks when:
218 // 1) Turning off the timer and turning it right back on. 224 // 1) Turning off the timer and turning it right back on.
219 // 2) Jittery data is passed to SetTimebaseAndInterval(). 225 // 2) Jittery data is passed to SetTimebaseAndInterval().
220 if (new_tick_target - last_tick_time_ <= 226 if (new_tick_target - last_tick_time_ <=
221 new_interval / static_cast<int>(1.0 / kDoubleTickThreshold)) 227 new_interval / static_cast<int>(1.0 / kDoubleTickThreshold))
222 new_tick_target += new_interval; 228 new_tick_target += new_interval;
223 229
224 return new_tick_target; 230 return new_tick_target;
225 } 231 }
226 232
227 void DelayBasedTimeSource::PostNextTickTask(base::TimeTicks now) { 233 void DelayBasedTimeSource::PostNextTickTask(base::TimeTicks now) {
228 base::TimeTicks new_tick_target = NextTickTarget(now); 234 base::TimeTicks new_tick_target = NextTickTarget(now);
229 235
230 // Post another task *before* the tick and update state 236 // Post another task *before* the tick and update state
231 base::TimeDelta delay = new_tick_target - now; 237 base::TimeDelta delay = new_tick_target - now;
232 DCHECK(delay.InMillisecondsF() <= 238 DCHECK(delay.InMillisecondsF() <=
233 next_parameters_.interval.InMillisecondsF() * 239 next_parameters_.interval.InMillisecondsF() *
234 (1.0 + kDoubleTickThreshold)); 240 (1.0 + kDoubleTickThreshold));
235 thread_->PostDelayedTask(base::Bind(&DelayBasedTimeSource::OnTimerFired, 241 thread_->PostDelayedTask(base::Bind(&DelayBasedTimeSource::OnTimerFired,
236 weak_factory_.GetWeakPtr()), 242 weak_factory_.GetWeakPtr()),
237 delay); 243 delay);
238 244
239 next_parameters_.tick_target = new_tick_target; 245 next_parameters_.tick_target = new_tick_target;
240 current_parameters_ = next_parameters_; 246 current_parameters_ = next_parameters_;
241 } 247 }
242 248
243 } // namespace cc 249 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698