| Index: media/cast/cast_ntp_tick_clock.h
|
| diff --git a/media/cast/cast_ntp_tick_clock.h b/media/cast/cast_ntp_tick_clock.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..91aea11c29769f72f730f9f071e3cdc82f72ba91
|
| --- /dev/null
|
| +++ b/media/cast/cast_ntp_tick_clock.h
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_
|
| +#define MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/time/default_tick_clock.h"
|
| +#include "base/time/tick_clock.h"
|
| +#include "base/time/time.h"
|
| +#include "media/cast/cast_defines.h"
|
| +
|
| +namespace media {
|
| +namespace cast {
|
| +
|
| +// Class that provide the a TickTime relative to NTP. The base TickTime does not
|
| +// reference a specific date. This version is number of ticks relative to 0h UTC
|
| +// on 1 January 1900.
|
| +// Note: We only synchronize with the system clock at creation time after that
|
| +// we only use our relative difference this can result in a drift relative to
|
| +// the system clock however this approach guarantees that out NTP time never
|
| +// decrease (if the user changes the computer clock, Time::Now() may actually
|
| +// decrease or jump).
|
| +
|
| +class CastNtpTickClock : public base::TickClock {
|
| + public:
|
| + CastNtpTickClock();
|
| + virtual ~CastNtpTickClock();
|
| +
|
| + virtual base::TimeTicks NowTicks() OVERRIDE;
|
| +
|
| + protected:
|
| + // Provided for testability.
|
| + void SetTickClock(base::TickClock* tick_clock);
|
| +
|
| + private:
|
| + base::DefaultTickClock default_tick_clock_;
|
| + base::TickClock* tick_clock_;
|
| + base::TimeDelta start_offset_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CastNtpTickClock);
|
| +};
|
| +
|
| +} // namespace cast
|
| +} // namespace media
|
| +
|
| +#endif // MEDIA_CAST_CAST_NTP_TICK_CLOCK_H_
|
| +
|
| +
|
|
|