Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: media/cast/cast_ntp_tick_clock.h

Issue 34623008: Change to calculate the real NTP in TimeTicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_
+
+

Powered by Google App Engine
This is Rietveld 408576698