Chromium Code Reviews| Index: webrtc/base/fakeclock.cc |
| diff --git a/webrtc/base/fakeclock.cc b/webrtc/base/fakeclock.cc |
| index e5aa3bc0a4fc3af0aecd8e58b395c54ce48f0d41..bcd720ff742f2687f6c0bb05c5e60672edec6314 100644 |
| --- a/webrtc/base/fakeclock.cc |
| +++ b/webrtc/base/fakeclock.cc |
| @@ -27,14 +27,24 @@ void FakeClock::SetTimeNanos(uint64_t nanos) { |
| time_ = nanos; |
| } |
| // If message queues are waiting in a socket select() with a timeout provided |
| - // by the OS, they should wake up to check if there are any messages ready to |
| - // be dispatched based on the fake time. |
| - MessageQueueManager::WakeAllMessageQueues(); |
| + // by the OS, they should wake up and dispatch all messages that are ready. |
| + MessageQueueManager::ProcessAllMessageQueues(); |
| } |
| void FakeClock::AdvanceTime(TimeDelta delta) { |
| - CritScope cs(&lock_); |
| - SetTimeNanos(time_ + delta.ToNanoseconds()); |
| + { |
| + CritScope cs(&lock_); |
| + time_ += delta.ToNanoseconds(); |
| + } |
| + MessageQueueManager::ProcessAllMessageQueues(); |
| +} |
| + |
| +ScopedFakeClock::ScopedFakeClock() { |
| + prev_clock_ = SetClockForTesting(this); |
| +} |
| + |
| +ScopedFakeClock::~ScopedFakeClock() { |
| + SetClockForTesting(prev_clock_); |
|
nisse-webrtc
2016/06/08 09:47:30
I think it's simpler to only ever allow one fake c
|
| } |
| } // namespace rtc |