OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H |
| 6 #define CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H |
| 7 |
| 8 #include "base/time/tick_clock.h" |
| 9 #include "base/time/time.h" |
| 10 |
| 11 namespace media { |
| 12 namespace cast { |
| 13 namespace test { |
| 14 |
| 15 class SkewedTickClock : public base::TickClock { |
| 16 public: |
| 17 explicit SkewedTickClock(base::TickClock* clock_); |
| 18 // |skew| > 1.0 means clock runs faster. |
| 19 // |offset| > 0 means clock returns times from the future. |
| 20 // Note, |offset| is cumulative. |
| 21 // Also note that changing the skew will never make the clock |
| 22 // jump forwards or backwards, only changing the offset will |
| 23 // do that. |
| 24 void SetSkew(double skew, base::TimeDelta offset); |
| 25 virtual base::TimeTicks NowTicks() OVERRIDE; |
| 26 |
| 27 private: |
| 28 base::TimeTicks SkewTicks(base::TimeTicks now); |
| 29 base::TickClock* clock_; |
| 30 double skew_; |
| 31 base::TimeTicks last_skew_set_time_; |
| 32 base::TimeTicks skew_clock_at_last_set_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(SkewedTickClock); |
| 35 }; |
| 36 |
| 37 } // namespace test |
| 38 } // namespace cast |
| 39 } // namespace media |
| 40 |
| 41 #endif // CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H |
OLD | NEW |