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

Issue 2016863003: Implemented ScopedFakeTime, faking rtc::TimeNanos. (Closed)

Created:
4 years, 6 months ago by nisse-webrtc
Modified:
4 years, 6 months ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Implemented ScopedFakeTime, faking rtc::TimeNanos. BUG=5940

Patch Set 1 #

Patch Set 2 : Add new file. #

Patch Set 3 : New FakeTimeInterface. Eliminate one layer of indirection. #

Total comments: 6

Patch Set 4 : Addressed comments. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+107 lines, -0 lines) Patch
M webrtc/base/base_tests.gyp View 1 chunk +1 line, -0 lines 0 comments Download
A webrtc/base/faketime.h View 1 2 1 chunk +50 lines, -0 lines 3 comments Download
M webrtc/base/timeutils.h View 1 2 1 chunk +13 lines, -0 lines 0 comments Download
M webrtc/base/timeutils.cc View 1 2 3 1 chunk +19 lines, -0 lines 0 comments Download
M webrtc/base/timeutils_unittest.cc View 1 2 2 chunks +24 lines, -0 lines 0 comments Download

Messages

Total messages: 10 (2 generated)
nisse-webrtc
Here's a first implementation of a ScopedFakeTime.
4 years, 6 months ago (2016-05-27 12:40:25 UTC) #2
pbos-webrtc
https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/timeutils.cc File webrtc/base/timeutils.cc (right): https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/timeutils.cc#newcode36 webrtc/base/timeutils.cc:36: FakeTimeInterface* global_fake_time = nullptr; g_fake_time https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/timeutils.cc#newcode41 webrtc/base/timeutils.cc:41: RTC_CHECK(!global_fake_time || ...
4 years, 6 months ago (2016-05-31 22:34:16 UTC) #3
pbos-webrtc
https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/faketime.h File webrtc/base/faketime.h (right): https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/faketime.h#newcode40 webrtc/base/faketime.h:40: ScopedFakeTime() : ScopedFakeTime(rtc::TimeNanos()) {} Is this one useful or ...
4 years, 6 months ago (2016-05-31 22:35:35 UTC) #4
nisse-webrtc
https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/faketime.h File webrtc/base/faketime.h (right): https://codereview.webrtc.org/2016863003/diff/40001/webrtc/base/faketime.h#newcode40 webrtc/base/faketime.h:40: ScopedFakeTime() : ScopedFakeTime(rtc::TimeNanos()) {} On 2016/05/31 22:35:35, pbos-webrtc wrote: ...
4 years, 6 months ago (2016-06-01 07:35:36 UTC) #5
pthatcher1
Adding Taylor, who recently wrote FakeClock which looks very similar. In short, I don't think ...
4 years, 6 months ago (2016-06-03 00:34:45 UTC) #7
nisse-webrtc
https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h File webrtc/base/faketime.h (right): https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h#newcode35 webrtc/base/faketime.h:35: class ScopedFakeTime : public FakeTime { On 2016/06/03 00:34:45, ...
4 years, 6 months ago (2016-06-03 11:40:07 UTC) #8
nisse-webrtc
https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h File webrtc/base/faketime.h (right): https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h#newcode35 webrtc/base/faketime.h:35: class ScopedFakeTime : public FakeTime { On 2016/06/03 00:34:45, ...
4 years, 6 months ago (2016-06-03 11:40:07 UTC) #9
Taylor Brandstetter
4 years, 6 months ago (2016-06-03 16:30:16 UTC) #10
https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h
File webrtc/base/faketime.h (right):

https://codereview.webrtc.org/2016863003/diff/60001/webrtc/base/faketime.h#ne...
webrtc/base/faketime.h:35: class ScopedFakeTime : public FakeTime {
On 2016/06/03 11:40:07, nisse-webrtc wrote:
> On 2016/06/03 00:34:45, pthatcher1 wrote:
> > Have you seen FakeClock in fakeclock.h? It looks *very* similar.
> > 
> > And ScopedFakeClock is being added to it in an upcoming CL.
> 
> It look very similar indeed. Great minds think alike ;-)
> 
> I'm happy to leave this to you. Taylor, have a look the ScopedFakeTime in this
> cl, maybe there's something there which is useful to you, or maybe there
isn't.

Aside from FakeTime taking a time in its constructor, and naming, I think our
implementations are exactly the same. I'm honestly amazed.

By the way, take a look at this upcoming CL:
https://codereview.webrtc.org/2024813004/

The goal is to handle events that piggyback off of each other. If the expiration
of one timeout triggers another timeout, then it's not enough to advance the
clock once, because that will only trigger the first timeout. So the
SIMULATED_WAIT macro advances the fake clock by 1ms ticks, processing all
pending events on each tick. Let me know what you think.

Powered by Google App Engine
This is Rietveld 408576698