1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/cast/test/skewed_tick_clock.h"
7 #include "base/time/time.h"
13 SkewedTickClock::SkewedTickClock(base::TickClock
* clock
)
16 last_skew_set_time_(clock_
->NowTicks()),
17 skew_clock_at_last_set_(last_skew_set_time_
) {
20 base::TimeTicks
SkewedTickClock::SkewTicks(base::TimeTicks now
) {
21 return base::TimeDelta::FromMicroseconds(
22 (now
- last_skew_set_time_
).InMicroseconds() * skew_
) +
23 skew_clock_at_last_set_
;
26 void SkewedTickClock::SetSkew(double skew
, base::TimeDelta offset
) {
27 base::TimeTicks now
= clock_
->NowTicks();
28 skew_clock_at_last_set_
= SkewTicks(now
) + offset
;
30 last_skew_set_time_
= now
;
33 base::TimeTicks
SkewedTickClock::NowTicks() {
34 return SkewTicks(clock_
->NowTicks());