| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // QuicTime represents one point in time, stored in microsecond resolution. | 5 // QuicTime represents one point in time, stored in microsecond resolution. |
| 6 // QuicTime is monotonically increasing, even across system clock adjustments. | 6 // QuicTime is monotonically increasing, even across system clock adjustments. |
| 7 // The epoch (time 0) of QuicTime is unspecified. | 7 // The epoch (time 0) of QuicTime is unspecified. |
| 8 // | 8 // |
| 9 // This implementation wraps the classes base::TimeTicks and base::TimeDelta. | 9 // This implementation wraps the classes base::TimeTicks and base::TimeDelta. |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 inline bool IsZero() const { return time_offset_ == 0; } | 99 inline bool IsZero() const { return time_offset_ == 0; } |
| 100 | 100 |
| 101 inline bool IsInfinite() const { | 101 inline bool IsInfinite() const { |
| 102 return time_offset_ == kQuicInfiniteTimeUs; | 102 return time_offset_ == kQuicInfiniteTimeUs; |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 base::TimeDelta delta_; | 106 base::TimeDelta delta_; |
| 107 friend inline bool operator==(QuicTime::Delta lhs, QuicTime::Delta rhs); | 107 friend inline bool operator==(QuicTime::Delta lhs, QuicTime::Delta rhs); |
| 108 friend inline bool operator<(QuicTime::Delta lhs, QuicTime::Delta rhs); | 108 friend inline bool operator<(QuicTime::Delta lhs, QuicTime::Delta rhs); |
| 109 friend inline QuicTime::Delta operator<<(QuicTime::Delta lhs, size_t rhs); |
| 110 friend inline QuicTime::Delta operator>>(QuicTime::Delta lhs, size_t rhs); |
| 109 | 111 |
| 110 // Highest number of microseconds that DateTimeOffset can hold. | 112 // Highest number of microseconds that DateTimeOffset can hold. |
| 111 static const int64_t kQuicInfiniteTimeUs = INT64_C(0x7fffffffffffffff) / 10; | 113 static const int64_t kQuicInfiniteTimeUs = INT64_C(0x7fffffffffffffff) / 10; |
| 112 | 114 |
| 113 explicit QUICTIME_CONSTEXPR Delta(int64_t time_offset) | 115 explicit QUICTIME_CONSTEXPR Delta(int64_t time_offset) |
| 114 : time_offset_(time_offset) {} | 116 : time_offset_(time_offset) {} |
| 115 | 117 |
| 116 int64_t time_offset_; | 118 int64_t time_offset_; |
| 117 friend class QuicTime; | 119 friend class QuicTime; |
| 118 friend class QuicClock; | 120 friend class QuicClock; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 229 } |
| 228 inline bool operator>(QuicTime::Delta lhs, QuicTime::Delta rhs) { | 230 inline bool operator>(QuicTime::Delta lhs, QuicTime::Delta rhs) { |
| 229 return rhs < lhs; | 231 return rhs < lhs; |
| 230 } | 232 } |
| 231 inline bool operator<=(QuicTime::Delta lhs, QuicTime::Delta rhs) { | 233 inline bool operator<=(QuicTime::Delta lhs, QuicTime::Delta rhs) { |
| 232 return !(rhs < lhs); | 234 return !(rhs < lhs); |
| 233 } | 235 } |
| 234 inline bool operator>=(QuicTime::Delta lhs, QuicTime::Delta rhs) { | 236 inline bool operator>=(QuicTime::Delta lhs, QuicTime::Delta rhs) { |
| 235 return !(lhs < rhs); | 237 return !(lhs < rhs); |
| 236 } | 238 } |
| 239 inline QuicTime::Delta operator<<(QuicTime::Delta lhs, size_t rhs) { |
| 240 return QuicTime::Delta(lhs.time_offset_ << rhs); |
| 241 } |
| 242 inline QuicTime::Delta operator>>(QuicTime::Delta lhs, size_t rhs) { |
| 243 return QuicTime::Delta(lhs.time_offset_ >> rhs); |
| 244 } |
| 245 |
| 237 // Non-member relational operators for QuicTime. | 246 // Non-member relational operators for QuicTime. |
| 238 inline bool operator==(QuicTime lhs, QuicTime rhs) { | 247 inline bool operator==(QuicTime lhs, QuicTime rhs) { |
| 239 return lhs.time_ == rhs.time_; | 248 return lhs.time_ == rhs.time_; |
| 240 } | 249 } |
| 241 inline bool operator!=(QuicTime lhs, QuicTime rhs) { | 250 inline bool operator!=(QuicTime lhs, QuicTime rhs) { |
| 242 return !(lhs == rhs); | 251 return !(lhs == rhs); |
| 243 } | 252 } |
| 244 inline bool operator<(QuicTime lhs, QuicTime rhs) { | 253 inline bool operator<(QuicTime lhs, QuicTime rhs) { |
| 245 return lhs.time_ < rhs.time_; | 254 return lhs.time_ < rhs.time_; |
| 246 } | 255 } |
| 247 inline bool operator>(QuicTime lhs, QuicTime rhs) { | 256 inline bool operator>(QuicTime lhs, QuicTime rhs) { |
| 248 return rhs < lhs; | 257 return rhs < lhs; |
| 249 } | 258 } |
| 250 inline bool operator<=(QuicTime lhs, QuicTime rhs) { | 259 inline bool operator<=(QuicTime lhs, QuicTime rhs) { |
| 251 return !(rhs < lhs); | 260 return !(rhs < lhs); |
| 252 } | 261 } |
| 253 inline bool operator>=(QuicTime lhs, QuicTime rhs) { | 262 inline bool operator>=(QuicTime lhs, QuicTime rhs) { |
| 254 return !(lhs < rhs); | 263 return !(lhs < rhs); |
| 255 } | 264 } |
| 256 | 265 |
| 257 } // namespace net | 266 } // namespace net |
| 258 | 267 |
| 259 #endif // NET_QUIC_QUIC_TIME_H_ | 268 #endif // NET_QUIC_QUIC_TIME_H_ |
| OLD | NEW |