| 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 14 matching lines...) Expand all Loading... |
| 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 ClockInterface* g_clock = nullptr; | 33 ClockInterface* g_clock = nullptr; |
| 34 | 34 |
| 35 void SetClock(ClockInterface* clock) { | 35 ClockInterface* SetClockForTesting(ClockInterface* clock) { |
| 36 ClockInterface* prev = g_clock; |
| 36 g_clock = clock; | 37 g_clock = clock; |
| 38 return prev; |
| 37 } | 39 } |
| 38 | 40 |
| 39 uint64_t TimeNanos() { | 41 uint64_t TimeNanos() { |
| 40 if (g_clock) { | 42 if (g_clock) { |
| 41 return g_clock->TimeNanos(); | 43 return g_clock->TimeNanos(); |
| 42 } | 44 } |
| 43 int64_t ticks; | 45 int64_t ticks; |
| 44 #if defined(WEBRTC_MAC) | 46 #if defined(WEBRTC_MAC) |
| 45 static mach_timebase_info_data_t timebase; | 47 static mach_timebase_info_data_t timebase; |
| 46 if (timebase.denom == 0) { | 48 if (timebase.denom == 0) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. | 171 if (expiry_in_leap_year && month <= 2 - 1) // |month| is zero based. |
| 170 day -= 1; | 172 day -= 1; |
| 171 | 173 |
| 172 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| | 174 // Combine all variables into seconds from 1970-01-01 00:00 (except |month| |
| 173 // which was accumulated into |day| above). | 175 // which was accumulated into |day| above). |
| 174 return (((static_cast<int64_t> | 176 return (((static_cast<int64_t> |
| 175 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; | 177 (year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace rtc | 180 } // namespace rtc |
| OLD | NEW |