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 // QuicBandwidth represents a bandwidth, stored in bits per second resolution. | 5 // QuicBandwidth represents a bandwidth, stored in bits per second resolution. |
6 | 6 |
7 #ifndef NET_QUIC_QUIC_BANDWIDTH_H_ | 7 #ifndef NET_QUIC_QUIC_BANDWIDTH_H_ |
8 #define NET_QUIC_QUIC_BANDWIDTH_H_ | 8 #define NET_QUIC_QUIC_BANDWIDTH_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 inline QuicBandwidth operator-(QuicBandwidth lhs, QuicBandwidth rhs) { | 98 inline QuicBandwidth operator-(QuicBandwidth lhs, QuicBandwidth rhs) { |
99 return QuicBandwidth(lhs.bits_per_second_ - rhs.bits_per_second_); | 99 return QuicBandwidth(lhs.bits_per_second_ - rhs.bits_per_second_); |
100 } | 100 } |
101 inline QuicBandwidth operator*(QuicBandwidth lhs, float rhs) { | 101 inline QuicBandwidth operator*(QuicBandwidth lhs, float rhs) { |
102 return QuicBandwidth( | 102 return QuicBandwidth( |
103 static_cast<int64_t>(std::llround(lhs.bits_per_second_ * rhs))); | 103 static_cast<int64_t>(std::llround(lhs.bits_per_second_ * rhs))); |
104 } | 104 } |
105 inline QuicBandwidth operator*(float lhs, QuicBandwidth rhs) { | 105 inline QuicBandwidth operator*(float lhs, QuicBandwidth rhs) { |
106 return rhs * lhs; | 106 return rhs * lhs; |
107 } | 107 } |
| 108 inline QuicByteCount operator*(QuicBandwidth lhs, QuicTime::Delta rhs) { |
| 109 return lhs.ToBytesPerPeriod(rhs); |
| 110 } |
| 111 inline QuicByteCount operator*(QuicTime::Delta lhs, QuicBandwidth rhs) { |
| 112 return rhs * lhs; |
| 113 } |
108 | 114 |
109 // Override stream output operator for gtest. | 115 // Override stream output operator for gtest. |
110 inline std::ostream& operator<<(std::ostream& output, | 116 inline std::ostream& operator<<(std::ostream& output, |
111 const QuicBandwidth bandwidth) { | 117 const QuicBandwidth bandwidth) { |
112 output << bandwidth.ToDebugValue(); | 118 output << bandwidth.ToDebugValue(); |
113 return output; | 119 return output; |
114 } | 120 } |
115 | 121 |
116 } // namespace net | 122 } // namespace net |
117 #endif // NET_QUIC_QUIC_BANDWIDTH_H_ | 123 #endif // NET_QUIC_QUIC_BANDWIDTH_H_ |
OLD | NEW |