Remove INJECT_EVENTS permissions from test APKs.
[chromium-blink-merge.git] / media / cast / test / skewed_tick_clock.cc
blob272c61e6c9882e4e2b75f436f5d544a8685e4c86
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"
9 namespace media {
10 namespace cast {
11 namespace test {
13 SkewedTickClock::SkewedTickClock(base::TickClock* clock)
14 : clock_(clock),
15 skew_(1.0),
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;
29 skew_ = skew;
30 last_skew_set_time_ = now;
33 base::TimeTicks SkewedTickClock::NowTicks() {
34 return SkewTicks(clock_->NowTicks());
37 } // namespace test
38 } // namespace cast
39 } // namespace media