Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / cast / test / skewed_tick_clock.h
blobe1dc81e0f717a0562a51634164de701b48711b68
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 #ifndef CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H
6 #define CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H
8 #include "base/time/tick_clock.h"
9 #include "base/time/time.h"
11 namespace media {
12 namespace cast {
13 namespace test {
15 // Wraps a base::TickClock, and lets you change the speed and offset
16 // of time compared to the wrapped clock. See SetSkew for how usage.
17 class SkewedTickClock : public base::TickClock {
18 public:
19 // Does not take ownership of |clock_|.
20 explicit SkewedTickClock(base::TickClock* clock_);
21 // |skew| > 1.0 means clock runs faster.
22 // |offset| > 0 means clock returns times from the future.
23 // Note, |offset| is cumulative.
24 // Also note that changing the skew will never make the clock
25 // jump forwards or backwards, only changing the offset will
26 // do that.
27 void SetSkew(double skew, base::TimeDelta offset);
28 base::TimeTicks NowTicks() final;
30 private:
31 base::TimeTicks SkewTicks(base::TimeTicks now);
32 base::TickClock* clock_; // Not owned.
33 double skew_;
34 base::TimeTicks last_skew_set_time_;
35 base::TimeTicks skew_clock_at_last_set_;
37 DISALLOW_COPY_AND_ASSIGN(SkewedTickClock);
40 } // namespace test
41 } // namespace cast
42 } // namespace media
44 #endif // CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H