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

Unified Diff: media/cast/test/skewed_tick_clock.cc

Issue 289083002: Cast: Add tests for clocks being slow/fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 7 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
« no previous file with comments | « media/cast/test/skewed_tick_clock.h ('k') | media/cast/test/utility/udp_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/skewed_tick_clock.cc
diff --git a/media/cast/test/skewed_tick_clock.cc b/media/cast/test/skewed_tick_clock.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fd3fb3cc4525188f6294bf8790a5af3cb23b4f7c
--- /dev/null
+++ b/media/cast/test/skewed_tick_clock.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 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.
+
+#include "media/cast/test/skewed_tick_clock.h"
+
+#include "base/time/time.h"
+
+namespace media {
+namespace cast {
+namespace test {
+
+SkewedTickClock::SkewedTickClock(base::TickClock* clock)
+ : clock_(clock),
+ skew_(1.0),
+ last_skew_set_time_(clock_->NowTicks()),
+ skew_clock_at_last_set_(last_skew_set_time_) {
+}
+
+base::TimeTicks SkewedTickClock::SkewTicks(base::TimeTicks now) {
+ return base::TimeDelta::FromMicroseconds(
+ (now - last_skew_set_time_).InMicroseconds() * skew_) +
+ skew_clock_at_last_set_;
+}
+
+void SkewedTickClock::SetSkew(double skew, base::TimeDelta offset) {
+ base::TimeTicks now = clock_->NowTicks();
+ last_skew_set_time_ = now;
+ skew_clock_at_last_set_ = SkewTicks(now) + offset;
+}
+
+base::TimeTicks SkewedTickClock::NowTicks() {
+ return SkewTicks(clock_->NowTicks());
+}
+
+} // namespace test
+} // namespace cast
+} // namespace media
« no previous file with comments | « media/cast/test/skewed_tick_clock.h ('k') | media/cast/test/utility/udp_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698