OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 static bool use_fake_clock_; | 76 static bool use_fake_clock_; |
77 static int64_t fake_ticks_; | 77 static int64_t fake_ticks_; |
78 | 78 |
79 int64_t ticks_; | 79 int64_t ticks_; |
80 }; | 80 }; |
81 | 81 |
82 // Represents a time delta in ticks. | 82 // Represents a time delta in ticks. |
83 class TickInterval { | 83 class TickInterval { |
84 public: | 84 public: |
85 TickInterval(); | 85 TickInterval(); |
86 explicit TickInterval(int64_t interval); | |
Andrew MacDonald
2015/10/21 00:29:28
Using this constructor is the most natural way for
| |
86 | 87 |
87 int64_t Milliseconds() const; | 88 int64_t Milliseconds() const; |
88 int64_t Microseconds() const; | 89 int64_t Microseconds() const; |
89 | 90 |
90 // Returns the sum of two TickIntervals as a TickInterval. | 91 // Returns the sum of two TickIntervals as a TickInterval. |
91 friend TickInterval operator+(const TickInterval& lhs, | 92 friend TickInterval operator+(const TickInterval& lhs, |
92 const TickInterval& rhs); | 93 const TickInterval& rhs); |
93 TickInterval& operator+=(const TickInterval& rhs); | 94 TickInterval& operator+=(const TickInterval& rhs); |
94 | 95 |
95 // Returns a TickInterval corresponding to rhs - lhs. | 96 // Returns a TickInterval corresponding to rhs - lhs. |
96 friend TickInterval operator-(const TickInterval& lhs, | 97 friend TickInterval operator-(const TickInterval& lhs, |
97 const TickInterval& rhs); | 98 const TickInterval& rhs); |
98 TickInterval& operator-=(const TickInterval& rhs); | 99 TickInterval& operator-=(const TickInterval& rhs); |
99 | 100 |
100 friend bool operator>(const TickInterval& lhs, const TickInterval& rhs); | 101 friend bool operator>(const TickInterval& lhs, const TickInterval& rhs); |
101 friend bool operator<=(const TickInterval& lhs, const TickInterval& rhs); | 102 friend bool operator<=(const TickInterval& lhs, const TickInterval& rhs); |
102 friend bool operator<(const TickInterval& lhs, const TickInterval& rhs); | 103 friend bool operator<(const TickInterval& lhs, const TickInterval& rhs); |
103 friend bool operator>=(const TickInterval& lhs, const TickInterval& rhs); | 104 friend bool operator>=(const TickInterval& lhs, const TickInterval& rhs); |
104 | 105 |
105 private: | 106 private: |
106 explicit TickInterval(int64_t interval); | |
107 | |
108 friend class TickTime; | 107 friend class TickTime; |
109 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); | 108 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); |
110 | 109 |
111 private: | 110 private: |
112 int64_t interval_; | 111 int64_t interval_; |
113 }; | 112 }; |
114 | 113 |
115 inline TickInterval operator+(const TickInterval& lhs, | 114 inline TickInterval operator+(const TickInterval& lhs, |
116 const TickInterval& rhs) { | 115 const TickInterval& rhs) { |
117 return TickInterval(lhs.interval_ + rhs.interval_); | 116 return TickInterval(lhs.interval_ + rhs.interval_); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 } | 288 } |
290 | 289 |
291 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { | 290 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { |
292 interval_ -= rhs.interval_; | 291 interval_ -= rhs.interval_; |
293 return *this; | 292 return *this; |
294 } | 293 } |
295 | 294 |
296 } // namespace webrtc | 295 } // namespace webrtc |
297 | 296 |
298 #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TICK_UTIL_H_ | 297 #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TICK_UTIL_H_ |
OLD | NEW |