Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/base/simulatedclock.h" | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/base/messagequeue.h" | |
| 15 | |
| 16 namespace rtc { | |
| 17 | |
| 18 uint64_t SimulatedClock::TimeNanos() const { | |
| 19 CritScope cs(&lock_); | |
| 20 return time_; | |
| 21 } | |
| 22 | |
| 23 void SimulatedClock::SetTimeNanos(uint64_t nanos) { | |
| 24 { | |
| 25 CritScope cs(&lock_); | |
| 26 RTC_DCHECK(nanos >= time_); | |
| 27 time_ = nanos; | |
| 28 } | |
| 29 MessageQueueManager::WakeAllMessageQueues(); | |
|
juberti2
2016/04/25 20:18:22
A comment explaining the intent here would be usef
Taylor Brandstetter
2016/04/26 01:22:32
Done.
| |
| 30 } | |
| 31 | |
| 32 void SimulatedClock::AdvanceTimeNanos(uint64_t nanos) { | |
| 33 CritScope cs(&lock_); | |
| 34 SetTimeNanos(time_ + nanos); | |
| 35 } | |
| 36 | |
| 37 void SimulatedClock::AdvanceTimeMicros(uint64_t micros) { | |
| 38 AdvanceTimeNanos(micros * 1000); | |
| 39 } | |
| 40 | |
| 41 void SimulatedClock::AdvanceTimeMillis(uint64_t millis) { | |
| 42 AdvanceTimeNanos(millis * 1000 * 1000); | |
| 43 } | |
| 44 | |
| 45 void SimulatedClock::AdvanceTimeSeconds(uint64_t seconds) { | |
| 46 AdvanceTimeNanos(seconds * 1000 * 1000 * 1000); | |
| 47 } | |
| 48 | |
| 49 } // namespace rtc | |
| OLD | NEW |