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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 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_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { 58 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) {
59 if (transmission_info.retransmittable_frames == nullptr) { 59 if (transmission_info.retransmittable_frames == nullptr) {
60 return false; 60 return false;
61 } 61 }
62 return transmission_info.retransmittable_frames->HasCryptoHandshake() == 62 return transmission_info.retransmittable_frames->HasCryptoHandshake() ==
63 IS_HANDSHAKE; 63 IS_HANDSHAKE;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") 68 #define ENDPOINT \
69 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ")
69 70
70 QuicSentPacketManager::QuicSentPacketManager( 71 QuicSentPacketManager::QuicSentPacketManager(
71 bool is_server, 72 Perspective perspective,
72 const QuicClock* clock, 73 const QuicClock* clock,
73 QuicConnectionStats* stats, 74 QuicConnectionStats* stats,
74 CongestionControlType congestion_control_type, 75 CongestionControlType congestion_control_type,
75 LossDetectionType loss_type, 76 LossDetectionType loss_type,
76 bool is_secure) 77 bool is_secure)
77 : unacked_packets_(), 78 : unacked_packets_(),
78 is_server_(is_server), 79 perspective_(perspective),
79 clock_(clock), 80 clock_(clock),
80 stats_(stats), 81 stats_(stats),
81 debug_delegate_(nullptr), 82 debug_delegate_(nullptr),
82 network_change_visitor_(nullptr), 83 network_change_visitor_(nullptr),
83 initial_congestion_window_(is_secure ? kInitialCongestionWindowSecure 84 initial_congestion_window_(is_secure ? kInitialCongestionWindowSecure
84 : kInitialCongestionWindowInsecure), 85 : kInitialCongestionWindowInsecure),
85 send_algorithm_( 86 send_algorithm_(
86 SendAlgorithmInterface::Create(clock, 87 SendAlgorithmInterface::Create(clock,
87 &rtt_stats_, 88 &rtt_stats_,
88 congestion_control_type, 89 congestion_control_type,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 if (config.HasReceivedConnectionOptions() && 161 if (config.HasReceivedConnectionOptions() &&
161 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { 162 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) {
162 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); 163 loss_algorithm_.reset(LossDetectionInterface::Create(kTime));
163 } 164 }
164 if (config.HasReceivedSocketReceiveBuffer()) { 165 if (config.HasReceivedSocketReceiveBuffer()) {
165 receive_buffer_bytes_ = 166 receive_buffer_bytes_ =
166 max(kMinSocketReceiveBuffer, 167 max(kMinSocketReceiveBuffer,
167 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); 168 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer()));
168 } 169 }
169 send_algorithm_->SetFromConfig(config, is_server_, using_pacing_); 170 send_algorithm_->SetFromConfig(config, perspective_, using_pacing_);
170 171
171 if (network_change_visitor_ != nullptr) { 172 if (network_change_visitor_ != nullptr) {
172 network_change_visitor_->OnCongestionWindowChange(); 173 network_change_visitor_->OnCongestionWindowChange();
173 } 174 }
174 } 175 }
175 176
176 bool QuicSentPacketManager::ResumeConnectionState( 177 bool QuicSentPacketManager::ResumeConnectionState(
177 const CachedNetworkParameters& cached_network_params) { 178 const CachedNetworkParameters& cached_network_params) {
178 if (cached_network_params.has_min_rtt_ms()) { 179 if (cached_network_params.has_min_rtt_ms()) {
179 uint32 initial_rtt_us = 180 uint32 initial_rtt_us =
180 kNumMicrosPerMilli * cached_network_params.min_rtt_ms(); 181 kNumMicrosPerMilli * cached_network_params.min_rtt_ms();
181 rtt_stats_.set_initial_rtt_us( 182 rtt_stats_.set_initial_rtt_us(
182 max(kMinInitialRoundTripTimeUs, 183 max(kMinInitialRoundTripTimeUs,
183 min(kMaxInitialRoundTripTimeUs, initial_rtt_us))); 184 min(kMaxInitialRoundTripTimeUs, initial_rtt_us)));
184 } 185 }
185 return send_algorithm_->ResumeConnectionState(cached_network_params); 186 return send_algorithm_->ResumeConnectionState(cached_network_params);
186 } 187 }
187 188
188 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { 189 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) {
189 if (n_connection_simulation_) { 190 if (n_connection_simulation_) {
190 // Ensure the number of connections is between 1 and 5. 191 // Ensure the number of connections is between 1 and 5.
191 send_algorithm_->SetNumEmulatedConnections( 192 send_algorithm_->SetNumEmulatedConnections(
192 min<size_t>(5, max<size_t>(1, num_streams))); 193 min<size_t>(5, max<size_t>(1, num_streams)));
193 } 194 }
194 } 195 }
195 196
196 bool QuicSentPacketManager::HasClientSentConnectionOption( 197 bool QuicSentPacketManager::HasClientSentConnectionOption(
197 const QuicConfig& config, QuicTag tag) const { 198 const QuicConfig& config, QuicTag tag) const {
198 if (is_server_) { 199 if (perspective_ == Perspective::IS_SERVER) {
199 if (config.HasReceivedConnectionOptions() && 200 if (config.HasReceivedConnectionOptions() &&
200 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) { 201 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) {
201 return true; 202 return true;
202 } 203 }
203 } else if (config.HasSendConnectionOptions() && 204 } else if (config.HasSendConnectionOptions() &&
204 ContainsQuicTag(config.SendConnectionOptions(), tag)) { 205 ContainsQuicTag(config.SendConnectionOptions(), tag)) {
205 return true; 206 return true;
206 } 207 }
207 return false; 208 return false;
208 } 209 }
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as 943 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as
943 // the default granularity of the Linux kernel's FQ qdisc. 944 // the default granularity of the Linux kernel's FQ qdisc.
944 using_pacing_ = true; 945 using_pacing_ = true;
945 send_algorithm_.reset( 946 send_algorithm_.reset(
946 new PacingSender(send_algorithm_.release(), 947 new PacingSender(send_algorithm_.release(),
947 QuicTime::Delta::FromMilliseconds(1), 948 QuicTime::Delta::FromMilliseconds(1),
948 kInitialUnpacedBurst)); 949 kInitialUnpacedBurst));
949 } 950 }
950 951
951 } // namespace net 952 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698