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

Unified Diff: net/quic/quic_time.h

Issue 2132623002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing comment about RPCs Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_sustained_bandwidth_recorder_test.cc ('k') | net/quic/quic_time_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_time.h
diff --git a/net/quic/quic_time.h b/net/quic/quic_time.h
index 63b2a342ea4571a0c72392fb14c64a0d3ce0fdd7..3c5a670e97d7f4b4d29f61b9535aba912f3a3f9b 100644
--- a/net/quic/quic_time.h
+++ b/net/quic/quic_time.h
@@ -70,22 +70,6 @@ class NET_EXPORT_PRIVATE QuicTime {
// Converts the time offset to a rounded number of microseconds.
inline int64_t ToMicroseconds() const { return time_offset_; }
- inline Delta Add(Delta delta) const WARN_UNUSED_RESULT {
- return Delta(time_offset_ + delta.time_offset_);
- }
-
- inline Delta Subtract(Delta delta) const WARN_UNUSED_RESULT {
- return Delta(time_offset_ - delta.time_offset_);
- }
-
- inline Delta Multiply(int i) const WARN_UNUSED_RESULT {
- return Delta(time_offset_ * i);
- }
-
- inline Delta Multiply(double d) const WARN_UNUSED_RESULT {
- return Delta(time_offset_ * d);
- }
-
// Returns the larger delta of time1 and time2.
static inline Delta Max(Delta delta1, Delta delta2) {
return delta1 < delta2 ? delta2 : delta1;
@@ -109,8 +93,19 @@ class NET_EXPORT_PRIVATE QuicTime {
friend inline QuicTime::Delta operator<<(QuicTime::Delta lhs, size_t rhs);
friend inline QuicTime::Delta operator>>(QuicTime::Delta lhs, size_t rhs);
- // Highest number of microseconds that DateTimeOffset can hold.
- static const int64_t kQuicInfiniteTimeUs = INT64_C(0x7fffffffffffffff) / 10;
+ friend inline QuicTime::Delta operator+(QuicTime::Delta lhs,
+ QuicTime::Delta rhs);
+ friend inline QuicTime::Delta operator-(QuicTime::Delta lhs,
+ QuicTime::Delta rhs);
+ friend inline QuicTime::Delta operator*(QuicTime::Delta lhs, int rhs);
+ friend inline QuicTime::Delta operator*(QuicTime::Delta lhs, double rhs);
+
+ friend inline QuicTime operator+(QuicTime lhs, QuicTime::Delta rhs);
+ friend inline QuicTime operator-(QuicTime lhs, QuicTime::Delta rhs);
+ friend inline QuicTime::Delta operator-(QuicTime lhs, QuicTime rhs);
+
+ static const int64_t kQuicInfiniteTimeUs =
+ std::numeric_limits<int64_t>::max();
explicit QUICTIME_CONSTEXPR Delta(int64_t time_offset)
: time_offset_(time_offset) {}
@@ -144,23 +139,12 @@ class NET_EXPORT_PRIVATE QuicTime {
inline bool IsInitialized() const { return 0 != time_; }
- inline QuicTime Add(Delta delta) const WARN_UNUSED_RESULT {
- return QuicTime(time_ + delta.time_offset_);
- }
-
- inline QuicTime Subtract(Delta delta) const WARN_UNUSED_RESULT {
- return QuicTime(time_ - delta.time_offset_);
- }
-
- inline Delta Subtract(QuicTime other) const WARN_UNUSED_RESULT {
- return Delta(time_ - other.time_);
- }
-
private:
friend inline bool operator==(QuicTime lhs, QuicTime rhs);
friend inline bool operator<(QuicTime lhs, QuicTime rhs);
- friend class QuicClock;
- friend class QuicClockTest;
+ friend inline QuicTime operator+(QuicTime lhs, QuicTime::Delta rhs);
+ friend inline QuicTime operator-(QuicTime lhs, QuicTime::Delta rhs);
+ friend inline QuicTime::Delta operator-(QuicTime lhs, QuicTime rhs);
explicit QUICTIME_CONSTEXPR QuicTime(int64_t time) : time_(time) {}
@@ -169,7 +153,7 @@ class NET_EXPORT_PRIVATE QuicTime {
// A QuicWallTime represents an absolute time that is globally consistent. In
// practice, clock-skew means that comparing values from different machines
-// requires some flexibility in interpretation.
+// requires some flexibility.
class NET_EXPORT_PRIVATE QuicWallTime {
public:
// FromUNIXSeconds constructs a QuicWallTime from a count of the seconds
@@ -263,6 +247,37 @@ inline bool operator>=(QuicTime lhs, QuicTime rhs) {
return !(lhs < rhs);
}
+// Non-member arithmetic operators for QuicTime::Delta.
+inline QuicTime::Delta operator+(QuicTime::Delta lhs, QuicTime::Delta rhs) {
+ return QuicTime::Delta(lhs.time_offset_ + rhs.time_offset_);
+}
+inline QuicTime::Delta operator-(QuicTime::Delta lhs, QuicTime::Delta rhs) {
+ return QuicTime::Delta(lhs.time_offset_ - rhs.time_offset_);
+}
+inline QuicTime::Delta operator*(QuicTime::Delta lhs, int rhs) {
+ return QuicTime::Delta(lhs.time_offset_ * rhs);
+}
+inline QuicTime::Delta operator*(QuicTime::Delta lhs, double rhs) {
+ return QuicTime::Delta(lhs.time_offset_ * rhs);
+}
+inline QuicTime::Delta operator*(int lhs, QuicTime::Delta rhs) {
+ return rhs * lhs;
+}
+inline QuicTime::Delta operator*(double lhs, QuicTime::Delta rhs) {
+ return rhs * lhs;
+}
+
+// Non-member arithmetic operators for QuicTime and QuicTime::Delta.
+inline QuicTime operator+(QuicTime lhs, QuicTime::Delta rhs) {
+ return QuicTime(lhs.time_ + rhs.time_offset_);
+}
+inline QuicTime operator-(QuicTime lhs, QuicTime::Delta rhs) {
+ return QuicTime(lhs.time_ - rhs.time_offset_);
+}
+inline QuicTime::Delta operator-(QuicTime lhs, QuicTime rhs) {
+ return QuicTime::Delta(lhs.time_ - rhs.time_);
+}
+
} // namespace net
#endif // NET_QUIC_QUIC_TIME_H_
« no previous file with comments | « net/quic/quic_sustained_bandwidth_recorder_test.cc ('k') | net/quic/quic_time_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698