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

Unified Diff: webrtc/base/fakeclock.h

Issue 2024813004: Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing another TSan warning. WebRtcSession wasn't completely shut down. Created 4 years, 6 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: webrtc/base/fakeclock.h
diff --git a/webrtc/base/fakeclock.h b/webrtc/base/fakeclock.h
index 2b3afdde05f684926621bcc95c2f917bfb7bd60f..4aecc54cc4ffee3e894cd4fef97760fce69338e8 100644
--- a/webrtc/base/fakeclock.h
+++ b/webrtc/base/fakeclock.h
@@ -19,6 +19,8 @@ namespace rtc {
// Fake clock for use with unit tests, which does not tick on its own.
// Starts at time 0.
+//
+// TODO(deadbeef): Unify with webrtc::SimulatedClock.
class FakeClock : public ClockInterface {
public:
~FakeClock() override {}
@@ -38,6 +40,17 @@ class FakeClock : public ClockInterface {
uint64_t time_ GUARDED_BY(lock_) = 0u;
};
+// Helper class that sets itself as the global clock in its constructor and
+// unsets it in its destructor.
+class ScopedFakeClock : public FakeClock {
+ public:
+ ScopedFakeClock();
+ ~ScopedFakeClock() override;
+
+ private:
+ ClockInterface* prev_clock_;
+};
+
} // namespace rtc
#endif // WEBRTC_BASE_FAKECLOCK_H_
« no previous file with comments | « webrtc/base/base_tests.gyp ('k') | webrtc/base/fakeclock.cc » ('j') | webrtc/base/fakeclock.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698