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

Side by Side Diff: webrtc/base/timeutils.cc

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/thread_checker_unittest.cc ('k') | webrtc/base/virtualsocketserver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 const uint32 HALF = 0x80000000; 35 const uint32 HALF = 0x80000000;
36 36
37 uint64 TimeNanos() { 37 uint64 TimeNanos() {
38 int64 ticks = 0; 38 int64 ticks = 0;
39 #if defined(WEBRTC_MAC) 39 #if defined(WEBRTC_MAC)
40 static mach_timebase_info_data_t timebase; 40 static mach_timebase_info_data_t timebase;
41 if (timebase.denom == 0) { 41 if (timebase.denom == 0) {
42 // Get the timebase if this is the first time we run. 42 // Get the timebase if this is the first time we run.
43 // Recommended by Apple's QA1398. 43 // Recommended by Apple's QA1398.
44 if (mach_timebase_info(&timebase) != KERN_SUCCESS) { 44 if (mach_timebase_info(&timebase) != KERN_SUCCESS) {
45 DCHECK(false); 45 RTC_DCHECK(false);
46 } 46 }
47 } 47 }
48 // Use timebase to convert absolute time tick units into nanoseconds. 48 // Use timebase to convert absolute time tick units into nanoseconds.
49 ticks = mach_absolute_time() * timebase.numer / timebase.denom; 49 ticks = mach_absolute_time() * timebase.numer / timebase.denom;
50 #elif defined(WEBRTC_POSIX) 50 #elif defined(WEBRTC_POSIX)
51 struct timespec ts; 51 struct timespec ts;
52 // TODO: Do we need to handle the case when CLOCK_MONOTONIC 52 // TODO: Do we need to handle the case when CLOCK_MONOTONIC
53 // is not supported? 53 // is not supported?
54 clock_gettime(CLOCK_MONOTONIC, &ts); 54 clock_gettime(CLOCK_MONOTONIC, &ts);
55 ticks = kNumNanosecsPerSec * static_cast<int64>(ts.tv_sec) + 55 ticks = kNumNanosecsPerSec * static_cast<int64>(ts.tv_sec) +
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (gettimeofday(&timeval, NULL) < 0) { 129 if (gettimeofday(&timeval, NULL) < 0) {
130 // Incredibly unlikely code path. 130 // Incredibly unlikely code path.
131 timeval.tv_sec = timeval.tv_usec = 0; 131 timeval.tv_sec = timeval.tv_usec = 0;
132 } 132 }
133 time_t secs = timeval.tv_sec; 133 time_t secs = timeval.tv_sec;
134 gmtime_r(&secs, tm); 134 gmtime_r(&secs, tm);
135 *microseconds = timeval.tv_usec; 135 *microseconds = timeval.tv_usec;
136 } 136 }
137 137
138 uint32 TimeAfter(int32 elapsed) { 138 uint32 TimeAfter(int32 elapsed) {
139 DCHECK_GE(elapsed, 0); 139 RTC_DCHECK_GE(elapsed, 0);
140 DCHECK_LT(static_cast<uint32>(elapsed), HALF); 140 RTC_DCHECK_LT(static_cast<uint32>(elapsed), HALF);
141 return Time() + elapsed; 141 return Time() + elapsed;
142 } 142 }
143 143
144 bool TimeIsBetween(uint32 earlier, uint32 middle, uint32 later) { 144 bool TimeIsBetween(uint32 earlier, uint32 middle, uint32 later) {
145 if (earlier <= later) { 145 if (earlier <= later) {
146 return ((earlier <= middle) && (middle <= later)); 146 return ((earlier <= middle) && (middle <= later));
147 } else { 147 } else {
148 return !((later < middle) && (middle < earlier)); 148 return !((later < middle) && (middle < earlier));
149 } 149 }
150 } 150 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (last_ts_ > 0xf0000000 && ts < 0x0fffffff) { 198 if (last_ts_ > 0xf0000000 && ts < 0x0fffffff) {
199 ++num_wrap_; 199 ++num_wrap_;
200 } 200 }
201 } 201 }
202 last_ts_ = ts; 202 last_ts_ = ts;
203 int64_t unwrapped_ts = ts + (num_wrap_ << 32); 203 int64_t unwrapped_ts = ts + (num_wrap_ << 32);
204 return unwrapped_ts; 204 return unwrapped_ts;
205 } 205 }
206 206
207 } // namespace rtc 207 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/thread_checker_unittest.cc ('k') | webrtc/base/virtualsocketserver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698