OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_ |
| 6 #define MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/time/default_tick_clock.h" |
| 10 #include "base/time/tick_clock.h" |
| 11 #include "base/time/time.h" |
| 12 #include "media/cast/cast_defines.h" |
| 13 |
| 14 namespace media { |
| 15 namespace cast { |
| 16 |
| 17 // Class that provide the a TickTime relative to NTP. The base TickTime does not |
| 18 // reference a specific date. This version is number of ticks relative to 0h UTC |
| 19 // on 1 January 1900. |
| 20 // Note: We only synchronize with the system clock at creation time after that |
| 21 // we only use our relative difference this can result in a drift relative to |
| 22 // the system clock however this approach guarantees that out NTP time never |
| 23 // decrease (if the user changes the computer clock, Time::Now() may actually |
| 24 // decrease or jump). |
| 25 |
| 26 class CastNtpTickClock : public base::TickClock { |
| 27 public: |
| 28 CastNtpTickClock(); |
| 29 virtual ~CastNtpTickClock(); |
| 30 |
| 31 virtual base::TimeTicks NowTicks() OVERRIDE; |
| 32 |
| 33 protected: |
| 34 // Provided for testability. |
| 35 void SetTickClock(base::TickClock* tick_clock); |
| 36 |
| 37 private: |
| 38 base::DefaultTickClock default_tick_clock_; |
| 39 base::TickClock* tick_clock_; |
| 40 base::TimeDelta start_offset_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(CastNtpTickClock); |
| 43 }; |
| 44 |
| 45 } // namespace cast |
| 46 } // namespace media |
| 47 |
| 48 #endif // MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_ |
| 49 |
| 50 |
OLD | NEW |