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 #include "net/quic/quic_bandwidth.h" | 5 #include "net/quic/quic_bandwidth.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 QuicBandwidth QuicBandwidth::Subtract(const QuicBandwidth& delta) const { | 94 QuicBandwidth QuicBandwidth::Subtract(const QuicBandwidth& delta) const { |
95 return QuicBandwidth(bits_per_second_ - delta.bits_per_second_); | 95 return QuicBandwidth(bits_per_second_ - delta.bits_per_second_); |
96 } | 96 } |
97 | 97 |
98 QuicBandwidth QuicBandwidth::Scale(float scale_factor) const { | 98 QuicBandwidth QuicBandwidth::Scale(float scale_factor) const { |
99 return QuicBandwidth(bits_per_second_ * scale_factor); | 99 return QuicBandwidth(bits_per_second_ * scale_factor); |
100 } | 100 } |
101 | 101 |
102 QuicTime::Delta QuicBandwidth::TransferTime(QuicByteCount bytes) const { | 102 QuicTime::Delta QuicBandwidth::TransferTime(QuicByteCount bytes) const { |
| 103 if (bits_per_second_ == 0) { |
| 104 return QuicTime::Delta::Zero(); |
| 105 } |
103 return QuicTime::Delta::FromMicroseconds( | 106 return QuicTime::Delta::FromMicroseconds( |
104 bytes * 8 * base::Time::kMicrosecondsPerSecond / bits_per_second_); | 107 bytes * 8 * base::Time::kMicrosecondsPerSecond / bits_per_second_); |
105 } | 108 } |
106 | 109 |
107 } // namespace net | 110 } // namespace net |
OLD | NEW |