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

Side by Side Diff: net/quic/quic_bandwidth.cc

Issue 1809123002: Pass QuicTime, QuicTime::Delta, and QuicBandwidth exclusively by value. Not flag protected. No func… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116970314
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_bandwidth.h ('k') | net/quic/quic_sent_packet_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « net/quic/quic_bandwidth.h ('k') | net/quic/quic_sent_packet_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698