OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 12 matching lines...) Expand all Loading... | |
23 #endif | 23 #endif |
24 #include <windows.h> | 24 #include <windows.h> |
25 #include <mmsystem.h> | 25 #include <mmsystem.h> |
26 #endif | 26 #endif |
27 | 27 |
28 #include "webrtc/base/checks.h" | 28 #include "webrtc/base/checks.h" |
29 #include "webrtc/base/timeutils.h" | 29 #include "webrtc/base/timeutils.h" |
30 | 30 |
31 namespace rtc { | 31 namespace rtc { |
32 | 32 |
33 namespace test { | |
34 | |
35 namespace { | |
36 FakeTimeInterface* global_fake_time = nullptr; | |
pbos-webrtc
2016/05/31 22:34:16
g_fake_time
nisse-webrtc
2016/06/01 07:35:35
Done.
| |
37 } // Anonymous | |
38 | |
39 void SetFakeTime(FakeTimeInterface* fake_time) { | |
40 // Allow setting fake_time only if it is null. | |
41 RTC_CHECK(!global_fake_time || !fake_time); | |
pbos-webrtc
2016/05/31 22:34:16
if (!fake_time)
RTC_CHECK(!global_fake_time);
R
nisse-webrtc
2016/06/01 07:35:35
Changed to
if (fake_time)
RTC_CHECK(!g_fake
| |
42 global_fake_time = fake_time; | |
43 } | |
44 | |
45 } // namespace test | |
46 | |
33 uint64_t TimeNanos() { | 47 uint64_t TimeNanos() { |
48 if (test::global_fake_time) | |
49 return test::global_fake_time->TimeNanos(); | |
50 | |
34 int64_t ticks = 0; | 51 int64_t ticks = 0; |
35 #if defined(WEBRTC_MAC) | 52 #if defined(WEBRTC_MAC) |
36 static mach_timebase_info_data_t timebase; | 53 static mach_timebase_info_data_t timebase; |
37 if (timebase.denom == 0) { | 54 if (timebase.denom == 0) { |
38 // Get the timebase if this is the first time we run. | 55 // Get the timebase if this is the first time we run. |
39 // Recommended by Apple's QA1398. | 56 // Recommended by Apple's QA1398. |
40 if (mach_timebase_info(&timebase) != KERN_SUCCESS) { | 57 if (mach_timebase_info(&timebase) != KERN_SUCCESS) { |
41 RTC_DCHECK(false); | 58 RTC_DCHECK(false); |
42 } | 59 } |
43 } | 60 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. | 178 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. |
162 day -= 1; | 179 day -= 1; |
163 | 180 |
164 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| | 181 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| |
165 // which was accumulated into |day| above). | 182 // which was accumulated into |day| above). |
166 return (((static_cast<int64_t> | 183 return (((static_cast<int64_t> |
167 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; | 184 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; |
168 } | 185 } |
169 | 186 |
170 } // namespace rtc | 187 } // namespace rtc |
OLD | NEW |