Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2005 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2005 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 17 matching lines...) Expand all Loading... | |
| 28 kNumNanosecsPerSec / kNumMillisecsPerSec; | 28 kNumNanosecsPerSec / kNumMillisecsPerSec; |
| 29 static const int64_t kNumNanosecsPerMicrosec = | 29 static const int64_t kNumNanosecsPerMicrosec = |
| 30 kNumNanosecsPerSec / kNumMicrosecsPerSec; | 30 kNumNanosecsPerSec / kNumMicrosecsPerSec; |
| 31 | 31 |
| 32 // January 1970, in NTP milliseconds. | 32 // January 1970, in NTP milliseconds. |
| 33 static const int64_t kJan1970AsNtpMillisecs = INT64_C(2208988800000); | 33 static const int64_t kJan1970AsNtpMillisecs = INT64_C(2208988800000); |
| 34 | 34 |
| 35 typedef uint32_t TimeStamp; | 35 typedef uint32_t TimeStamp; |
| 36 | 36 |
| 37 // Returns the current time in milliseconds. | 37 // Returns the current time in milliseconds. |
| 38 uint32_t Time(); | 38 uint32_t Time(); |
|
pthatcher1
2016/03/15 04:10:50
Can you make a Time32() that chooses 32-bit time,
honghaiz3
2016/03/15 17:35:33
Done. The last item will be done in the next CL wh
| |
| 39 | |
| 40 // Returns the current time in milliseconds. | |
| 41 int64_t Time64(); | |
| 42 | |
| 39 // Returns the current time in microseconds. | 43 // Returns the current time in microseconds. |
| 40 uint64_t TimeMicros(); | 44 uint64_t TimeMicros(); |
| 41 // Returns the current time in nanoseconds. | 45 // Returns the current time in nanoseconds. |
| 42 uint64_t TimeNanos(); | 46 uint64_t TimeNanos(); |
| 43 | 47 |
| 44 // Stores current time in *tm and microseconds in *microseconds. | 48 // Stores current time in *tm and microseconds in *microseconds. |
| 45 void CurrentTmTime(struct tm *tm, int *microseconds); | 49 void CurrentTmTime(struct tm *tm, int *microseconds); |
| 46 | 50 |
| 47 // Returns a future timestamp, 'elapsed' milliseconds from now. | 51 // Returns a future timestamp, 'elapsed' milliseconds from now. |
| 48 uint32_t TimeAfter(int32_t elapsed); | 52 uint32_t TimeAfter(int32_t elapsed); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 61 | 65 |
| 62 // Returns the earlier of two timestamps. | 66 // Returns the earlier of two timestamps. |
| 63 inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) { | 67 inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) { |
| 64 return TimeIsLaterOrEqual(ts1, ts2) ? ts1 : ts2; | 68 return TimeIsLaterOrEqual(ts1, ts2) ? ts1 : ts2; |
| 65 } | 69 } |
| 66 | 70 |
| 67 // Number of milliseconds that would elapse between 'earlier' and 'later' | 71 // Number of milliseconds that would elapse between 'earlier' and 'later' |
| 68 // timestamps. The value is negative if 'later' occurs before 'earlier'. | 72 // timestamps. The value is negative if 'later' occurs before 'earlier'. |
| 69 int32_t TimeDiff(uint32_t later, uint32_t earlier); | 73 int32_t TimeDiff(uint32_t later, uint32_t earlier); |
| 70 | 74 |
| 75 // Number of milliseconds that would elapse between 'earlier' and 'later' | |
| 76 // timestamps. The value is negative if 'later' occurs before 'earlier'. | |
| 77 int64_t TimeDiff64(int64_t later, int64_t earlier); | |
|
pthatcher1
2016/03/15 04:10:50
Same here with the names: make TimeDiff64 the defa
honghaiz3
2016/03/15 17:35:33
Will do this in the next CL because many of the 32
| |
| 78 | |
| 71 // The number of milliseconds that have elapsed since 'earlier'. | 79 // The number of milliseconds that have elapsed since 'earlier'. |
| 72 inline int32_t TimeSince(uint32_t earlier) { | 80 inline int32_t TimeSince(uint32_t earlier) { |
| 73 return TimeDiff(Time(), earlier); | 81 return TimeDiff(Time(), earlier); |
| 74 } | 82 } |
| 75 | 83 |
| 76 // The number of milliseconds that will elapse between now and 'later'. | 84 // The number of milliseconds that will elapse between now and 'later'. |
| 77 inline int32_t TimeUntil(uint32_t later) { | 85 inline int32_t TimeUntil(uint32_t later) { |
| 78 return TimeDiff(later, Time()); | 86 return TimeDiff(later, Time()); |
| 79 } | 87 } |
| 80 | 88 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 95 }; | 103 }; |
| 96 | 104 |
| 97 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of | 105 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of |
| 98 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that | 106 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that |
| 99 // is still 32 bits on many systems. | 107 // is still 32 bits on many systems. |
| 100 int64_t TmToSeconds(const std::tm& tm); | 108 int64_t TmToSeconds(const std::tm& tm); |
| 101 | 109 |
| 102 } // namespace rtc | 110 } // namespace rtc |
| 103 | 111 |
| 104 #endif // WEBRTC_BASE_TIMEUTILS_H_ | 112 #endif // WEBRTC_BASE_TIMEUTILS_H_ |
| OLD | NEW |