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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "media/cast/test/skewed_tick_clock.h"
6
7 #include "base/time/time.h"
8
9 namespace media {
10 namespace cast {
11 namespace test {
12
13 SkewedTickClock::SkewedTickClock(base::TickClock* clock)
14 : clock_(clock),
15 skew_(1.0),
16 last_skew_set_time_(clock_->NowTicks()),
17 skew_clock_at_last_set_(last_skew_set_time_) {
18 }
19
20 base::TimeTicks SkewedTickClock::SkewTicks(base::TimeTicks now) {
21 return base::TimeDelta::FromMicroseconds(
22 (now - last_skew_set_time_).InMicroseconds() * skew_) +
23 skew_clock_at_last_set_;
24 }
25
26 void SkewedTickClock::SetSkew(double skew, base::TimeDelta offset) {
27 base::TimeTicks now = clock_->NowTicks();
28 last_skew_set_time_ = now;
29 skew_clock_at_last_set_ = SkewTicks(now) + offset;
30 }
31
32 base::TimeTicks SkewedTickClock::NowTicks() {
33 return SkewTicks(clock_->NowTicks());
34 }
35
36 } // namespace test
37 } // namespace cast
38 } // namespace media
OLDNEW
« 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