| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/quic/quic_time.h" | 10 #include "net/quic/quic_time.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 int64_t QuicBandwidth::ToKBytesPerPeriod(QuicTime::Delta time_period) const { | 83 int64_t QuicBandwidth::ToKBytesPerPeriod(QuicTime::Delta time_period) const { |
| 84 return ToKBytesPerSecond() * time_period.ToMicroseconds() / | 84 return ToKBytesPerSecond() * time_period.ToMicroseconds() / |
| 85 kNumMicrosPerSecond; | 85 kNumMicrosPerSecond; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool QuicBandwidth::IsZero() const { | 88 bool QuicBandwidth::IsZero() const { |
| 89 return (bits_per_second_ == 0); | 89 return (bits_per_second_ == 0); |
| 90 } | 90 } |
| 91 | 91 |
| 92 QuicBandwidth QuicBandwidth::Add(const QuicBandwidth& delta) const { | 92 QuicBandwidth QuicBandwidth::Add(QuicBandwidth delta) const { |
| 93 return QuicBandwidth(bits_per_second_ + delta.bits_per_second_); | 93 return QuicBandwidth(bits_per_second_ + delta.bits_per_second_); |
| 94 } | 94 } |
| 95 | 95 |
| 96 QuicBandwidth QuicBandwidth::Subtract(const QuicBandwidth& delta) const { | 96 QuicBandwidth QuicBandwidth::Subtract(QuicBandwidth delta) const { |
| 97 return QuicBandwidth(bits_per_second_ - delta.bits_per_second_); | 97 return QuicBandwidth(bits_per_second_ - delta.bits_per_second_); |
| 98 } | 98 } |
| 99 | 99 |
| 100 QuicBandwidth QuicBandwidth::Scale(float scale_factor) const { | 100 QuicBandwidth QuicBandwidth::Scale(float scale_factor) const { |
| 101 return QuicBandwidth(static_cast<int64_t>(bits_per_second_ * scale_factor)); | 101 return QuicBandwidth(static_cast<int64_t>(bits_per_second_ * scale_factor)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 QuicTime::Delta QuicBandwidth::TransferTime(QuicByteCount bytes) const { | 104 QuicTime::Delta QuicBandwidth::TransferTime(QuicByteCount bytes) const { |
| 105 if (bits_per_second_ == 0) { | 105 if (bits_per_second_ == 0) { |
| 106 return QuicTime::Delta::Zero(); | 106 return QuicTime::Delta::Zero(); |
| 107 } | 107 } |
| 108 return QuicTime::Delta::FromMicroseconds(bytes * 8 * kNumMicrosPerSecond / | 108 return QuicTime::Delta::FromMicroseconds(bytes * 8 * kNumMicrosPerSecond / |
| 109 bits_per_second_); | 109 bits_per_second_); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace net | 112 } // namespace net |
| OLD | NEW |