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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ping_alarm_( | 233 ping_alarm_( |
234 alarm_factory_->CreateAlarm(arena_.New<PingAlarmDelegate>(this), | 234 alarm_factory_->CreateAlarm(arena_.New<PingAlarmDelegate>(this), |
235 &arena_)), | 235 &arena_)), |
236 mtu_discovery_alarm_(alarm_factory_->CreateAlarm( | 236 mtu_discovery_alarm_(alarm_factory_->CreateAlarm( |
237 arena_.New<MtuDiscoveryAlarmDelegate>(this), | 237 arena_.New<MtuDiscoveryAlarmDelegate>(this), |
238 &arena_)), | 238 &arena_)), |
239 visitor_(nullptr), | 239 visitor_(nullptr), |
240 debug_visitor_(nullptr), | 240 debug_visitor_(nullptr), |
241 packet_generator_(connection_id_, | 241 packet_generator_(connection_id_, |
242 &framer_, | 242 &framer_, |
| 243 random_generator_, |
243 helper->GetBufferAllocator(), | 244 helper->GetBufferAllocator(), |
244 this), | 245 this), |
245 idle_network_timeout_(QuicTime::Delta::Infinite()), | 246 idle_network_timeout_(QuicTime::Delta::Infinite()), |
246 handshake_timeout_(QuicTime::Delta::Infinite()), | 247 handshake_timeout_(QuicTime::Delta::Infinite()), |
247 time_of_last_received_packet_(clock_->ApproximateNow()), | 248 time_of_last_received_packet_(clock_->ApproximateNow()), |
248 time_of_last_sent_new_packet_(clock_->ApproximateNow()), | 249 time_of_last_sent_new_packet_(clock_->ApproximateNow()), |
249 last_send_for_timeout_(clock_->ApproximateNow()), | 250 last_send_for_timeout_(clock_->ApproximateNow()), |
250 sent_packet_manager_(perspective, clock_, &stats_, kCubicBytes, kNack), | 251 sent_packet_manager_(perspective, clock_, &stats_, kCubicBytes, kNack), |
251 version_negotiation_state_(START_NEGOTIATION), | 252 version_negotiation_state_(START_NEGOTIATION), |
252 perspective_(perspective), | 253 perspective_(perspective), |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 ScopedRetransmissionScheduler alarm_delayer(this); | 1073 ScopedRetransmissionScheduler alarm_delayer(this); |
1073 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1074 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
1074 // The optimized path may be used for data only packets which fit into a | 1075 // The optimized path may be used for data only packets which fit into a |
1075 // standard buffer and don't need padding. | 1076 // standard buffer and don't need padding. |
1076 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() && | 1077 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() && |
1077 iov.total_length > kMaxPacketSize) { | 1078 iov.total_length > kMaxPacketSize) { |
1078 // Use the fast path to send full data packets. | 1079 // Use the fast path to send full data packets. |
1079 return packet_generator_.ConsumeDataFastPath(id, iov, offset, fin, | 1080 return packet_generator_.ConsumeDataFastPath(id, iov, offset, fin, |
1080 std::move(ack_listener)); | 1081 std::move(ack_listener)); |
1081 } | 1082 } |
1082 return packet_generator_.ConsumeData(id, iov, offset, fin, | 1083 return packet_generator_.ConsumeData(id, iov, offset, fin ? FIN : NO_FIN, |
1083 std::move(ack_listener)); | 1084 std::move(ack_listener)); |
1084 } | 1085 } |
1085 | 1086 |
1086 void QuicConnection::SendRstStream(QuicStreamId id, | 1087 void QuicConnection::SendRstStream(QuicStreamId id, |
1087 QuicRstStreamErrorCode error, | 1088 QuicRstStreamErrorCode error, |
1088 QuicStreamOffset bytes_written) { | 1089 QuicStreamOffset bytes_written) { |
1089 // Opportunistically bundle an ack with this outgoing packet. | 1090 // Opportunistically bundle an ack with this outgoing packet. |
1090 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1091 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
1091 packet_generator_.AddControlFrame( | 1092 packet_generator_.AddControlFrame( |
1092 QuicFrame(new QuicRstStreamFrame(id, error, bytes_written))); | 1093 QuicFrame(new QuicRstStreamFrame(id, error, bytes_written))); |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 | 2388 |
2388 void QuicConnection::CheckIfApplicationLimited() { | 2389 void QuicConnection::CheckIfApplicationLimited() { |
2389 if (queued_packets_.empty() && | 2390 if (queued_packets_.empty() && |
2390 !sent_packet_manager_.HasPendingRetransmissions() && | 2391 !sent_packet_manager_.HasPendingRetransmissions() && |
2391 !visitor_->WillingAndAbleToWrite()) { | 2392 !visitor_->WillingAndAbleToWrite()) { |
2392 sent_packet_manager_.OnApplicationLimited(); | 2393 sent_packet_manager_.OnApplicationLimited(); |
2393 } | 2394 } |
2394 } | 2395 } |
2395 | 2396 |
2396 } // namespace net | 2397 } // namespace net |
OLD | NEW |