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

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

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_single_thread_task_runner.cc ('k') | media/cast/test/skewed_tick_clock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/skewed_tick_clock.h
diff --git a/media/cast/test/skewed_tick_clock.h b/media/cast/test/skewed_tick_clock.h
new file mode 100644
index 0000000000000000000000000000000000000000..dcb538448c0719e05dd865fb3785683a61c4e4da
--- /dev/null
+++ b/media/cast/test/skewed_tick_clock.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H
+#define CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H
+
+#include "base/time/tick_clock.h"
+#include "base/time/time.h"
+
+namespace media {
+namespace cast {
+namespace test {
+
+// Wraps a base::TickClock, and lets you change the speed and offset
+// of time compared to the wrapped clock. See SetSkew for how usage.
+class SkewedTickClock : public base::TickClock {
+ public:
+ // Does not take ownership of |clock_|.
+ explicit SkewedTickClock(base::TickClock* clock_);
+ // |skew| > 1.0 means clock runs faster.
+ // |offset| > 0 means clock returns times from the future.
+ // Note, |offset| is cumulative.
+ // Also note that changing the skew will never make the clock
+ // jump forwards or backwards, only changing the offset will
+ // do that.
+ void SetSkew(double skew, base::TimeDelta offset);
+ virtual base::TimeTicks NowTicks() OVERRIDE;
+
+ private:
+ base::TimeTicks SkewTicks(base::TimeTicks now);
+ base::TickClock* clock_; // Not owned.
+ double skew_;
+ base::TimeTicks last_skew_set_time_;
+ base::TimeTicks skew_clock_at_last_set_;
+
+ DISALLOW_COPY_AND_ASSIGN(SkewedTickClock);
+};
+
+} // namespace test
+} // namespace cast
+} // namespace media
+
+#endif // CAST_MEDIA_TEST_SKEWED_TICK_CLOCK_H
« no previous file with comments | « media/cast/test/skewed_single_thread_task_runner.cc ('k') | media/cast/test/skewed_tick_clock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698