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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 static bool use_fake_clock_; | 78 static bool use_fake_clock_; |
79 static int64_t fake_ticks_; | 79 static int64_t fake_ticks_; |
80 | 80 |
81 int64_t ticks_; | 81 int64_t ticks_; |
82 }; | 82 }; |
83 | 83 |
84 // Represents a time delta in ticks. | 84 // Represents a time delta in ticks. |
85 class TickInterval { | 85 class TickInterval { |
86 public: | 86 public: |
87 TickInterval(); | 87 TickInterval(); |
| 88 explicit TickInterval(int64_t interval); |
88 | 89 |
89 int64_t Milliseconds() const; | 90 int64_t Milliseconds() const; |
90 int64_t Microseconds() const; | 91 int64_t Microseconds() const; |
91 | 92 |
92 // Returns the sum of two TickIntervals as a TickInterval. | 93 // Returns the sum of two TickIntervals as a TickInterval. |
93 friend TickInterval operator+(const TickInterval& lhs, | 94 friend TickInterval operator+(const TickInterval& lhs, |
94 const TickInterval& rhs); | 95 const TickInterval& rhs); |
95 TickInterval& operator+=(const TickInterval& rhs); | 96 TickInterval& operator+=(const TickInterval& rhs); |
96 | 97 |
97 // Returns a TickInterval corresponding to rhs - lhs. | 98 // Returns a TickInterval corresponding to rhs - lhs. |
98 friend TickInterval operator-(const TickInterval& lhs, | 99 friend TickInterval operator-(const TickInterval& lhs, |
99 const TickInterval& rhs); | 100 const TickInterval& rhs); |
100 TickInterval& operator-=(const TickInterval& rhs); | 101 TickInterval& operator-=(const TickInterval& rhs); |
101 | 102 |
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 friend bool operator<(const TickInterval& lhs, const TickInterval& rhs); | 105 friend bool operator<(const TickInterval& lhs, const TickInterval& rhs); |
105 friend bool operator>=(const TickInterval& lhs, const TickInterval& rhs); | 106 friend bool operator>=(const TickInterval& lhs, const TickInterval& rhs); |
106 | 107 |
107 private: | 108 private: |
108 explicit TickInterval(int64_t interval); | |
109 | |
110 friend class TickTime; | 109 friend class TickTime; |
111 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); | 110 friend TickInterval operator-(const TickTime& lhs, const TickTime& rhs); |
112 | 111 |
113 private: | 112 private: |
114 int64_t interval_; | 113 int64_t interval_; |
115 }; | 114 }; |
116 | 115 |
117 inline int64_t TickInterval::Milliseconds() const { | 116 inline int64_t TickInterval::Milliseconds() const { |
118 return TickTime::TicksToMilliseconds(interval_); | 117 return TickTime::TicksToMilliseconds(interval_); |
119 } | 118 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 194 } |
196 | 195 |
197 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { | 196 inline TickInterval& TickInterval::operator-=(const TickInterval& rhs) { |
198 interval_ -= rhs.interval_; | 197 interval_ -= rhs.interval_; |
199 return *this; | 198 return *this; |
200 } | 199 } |
201 | 200 |
202 } // namespace webrtc | 201 } // namespace webrtc |
203 | 202 |
204 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ | 203 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_TICK_UTIL_H_ |
OLD | NEW |