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

Side by Side Diff: webrtc/system_wrappers/include/tick_util.h

Issue 1512853002: Nuke TickTime::UseFakeClock. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 5 years 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 | « webrtc/call/congestion_controller.cc ('k') | webrtc/system_wrappers/source/tick_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 static int64_t TicksToMicroseconds(const int64_t ticks); 59 static int64_t TicksToMicroseconds(const int64_t ticks);
60 60
61 // Returns a TickTime that is ticks later than the passed TickTime. 61 // Returns a TickTime that is ticks later than the passed TickTime.
62 friend TickTime operator+(const TickTime lhs, const int64_t ticks); 62 friend TickTime operator+(const TickTime lhs, const int64_t ticks);
63 TickTime& operator+=(const int64_t& ticks); 63 TickTime& operator+=(const int64_t& ticks);
64 64
65 // Returns a TickInterval that is the difference in ticks beween rhs and lhs. 65 // Returns a TickInterval that is the difference in ticks beween rhs and lhs.
66 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); 66 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs);
67 67
68 // Call to engage the fake clock. This is useful for tests since relying on
69 // a real clock often makes the test flaky.
70 static void UseFakeClock(int64_t start_millisecond);
71
72 // Advance the fake clock. Must be called after UseFakeClock.
73 static void AdvanceFakeClock(int64_t milliseconds);
74
75 private: 68 private:
76 static int64_t QueryOsForTicks(); 69 static int64_t QueryOsForTicks();
77 70
78 static bool use_fake_clock_;
79 static int64_t fake_ticks_;
80
81 int64_t ticks_; 71 int64_t ticks_;
82 }; 72 };
83 73
84 // Represents a time delta in ticks. 74 // Represents a time delta in ticks.
85 class TickInterval { 75 class TickInterval {
86 public: 76 public:
87 TickInterval(); 77 TickInterval();
88 explicit TickInterval(int64_t interval); 78 explicit TickInterval(int64_t interval);
89 79
90 int64_t Milliseconds() const; 80 int64_t Milliseconds() const;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 149
160 inline TickTime::TickTime() 150 inline TickTime::TickTime()
161 : ticks_(0) { 151 : ticks_(0) {
162 } 152 }
163 153
164 inline TickTime::TickTime(int64_t ticks) 154 inline TickTime::TickTime(int64_t ticks)
165 : ticks_(ticks) { 155 : ticks_(ticks) {
166 } 156 }
167 157
168 inline TickTime TickTime::Now() { 158 inline TickTime TickTime::Now() {
169 if (use_fake_clock_) 159 return TickTime(QueryOsForTicks());
170 return TickTime(fake_ticks_);
171 else
172 return TickTime(QueryOsForTicks());
173 } 160 }
174 161
175 inline int64_t TickTime::Ticks() const { 162 inline int64_t TickTime::Ticks() const {
176 return ticks_; 163 return ticks_;
177 } 164 }
178 165
179 inline TickTime& TickTime::operator+=(const int64_t& ticks) { 166 inline TickTime& TickTime::operator+=(const int64_t& ticks) {
180 ticks_ += ticks; 167 ticks_ += ticks;
181 return *this; 168 return *this;
182 } 169 }
(...skipping 11 matching lines...) Expand all
194 } 181 }
195 182
196 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { 183 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) {
197 interval_ -= rhs.interval_; 184 interval_ -= rhs.interval_;
198 return *this; 185 return *this;
199 } 186 }
200 187
201 } // namespace webrtc 188 } // namespace webrtc
202 189
203 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ 190 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_
OLDNEW
« no previous file with comments | « webrtc/call/congestion_controller.cc ('k') | webrtc/system_wrappers/source/tick_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698