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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 /*delegate=*/nullptr)), | 274 /*delegate=*/nullptr)), |
275 version_negotiation_state_(START_NEGOTIATION), | 275 version_negotiation_state_(START_NEGOTIATION), |
276 perspective_(perspective), | 276 perspective_(perspective), |
277 connected_(true), | 277 connected_(true), |
278 can_truncate_connection_ids_(true), | 278 can_truncate_connection_ids_(true), |
279 mtu_discovery_target_(0), | 279 mtu_discovery_target_(0), |
280 mtu_probe_count_(0), | 280 mtu_probe_count_(0), |
281 packets_between_mtu_probes_(kPacketsBetweenMtuProbesBase), | 281 packets_between_mtu_probes_(kPacketsBetweenMtuProbesBase), |
282 next_mtu_probe_at_(kPacketsBetweenMtuProbesBase), | 282 next_mtu_probe_at_(kPacketsBetweenMtuProbesBase), |
283 largest_received_packet_size_(0), | 283 largest_received_packet_size_(0), |
284 largest_packet_size_supported_(std::numeric_limits<QuicByteCount>::max()), | |
285 goaway_sent_(false), | 284 goaway_sent_(false), |
286 goaway_received_(false), | 285 goaway_received_(false), |
287 multipath_enabled_(false), | 286 multipath_enabled_(false), |
288 write_error_occured_(false) { | 287 write_error_occured_(false) { |
289 DVLOG(1) << ENDPOINT | 288 DVLOG(1) << ENDPOINT |
290 << "Created connection with connection_id: " << connection_id; | 289 << "Created connection with connection_id: " << connection_id; |
291 framer_.set_visitor(this); | 290 framer_.set_visitor(this); |
292 framer_.set_received_entropy_calculator(&received_packet_manager_); | 291 framer_.set_received_entropy_calculator(&received_packet_manager_); |
293 if (!FLAGS_quic_receive_packet_once_decrypted) { | 292 if (!FLAGS_quic_receive_packet_once_decrypted) { |
294 last_stop_waiting_frame_.least_unacked = 0; | 293 last_stop_waiting_frame_.least_unacked = 0; |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 | 2441 |
2443 QuicByteCount QuicConnection::GetLimitedMaxPacketSize( | 2442 QuicByteCount QuicConnection::GetLimitedMaxPacketSize( |
2444 QuicByteCount suggested_max_packet_size) { | 2443 QuicByteCount suggested_max_packet_size) { |
2445 if (peer_address_.address().empty()) { | 2444 if (peer_address_.address().empty()) { |
2446 QUIC_BUG << "Attempted to use a connection without a valid peer address"; | 2445 QUIC_BUG << "Attempted to use a connection without a valid peer address"; |
2447 return suggested_max_packet_size; | 2446 return suggested_max_packet_size; |
2448 } | 2447 } |
2449 | 2448 |
2450 const QuicByteCount writer_limit = writer_->GetMaxPacketSize(peer_address()); | 2449 const QuicByteCount writer_limit = writer_->GetMaxPacketSize(peer_address()); |
2451 | 2450 |
2452 return std::min({suggested_max_packet_size, writer_limit, kMaxPacketSize, | 2451 QuicByteCount max_packet_size = suggested_max_packet_size; |
2453 largest_packet_size_supported_}); | 2452 if (max_packet_size > writer_limit) { |
| 2453 max_packet_size = writer_limit; |
| 2454 } |
| 2455 if (max_packet_size > kMaxPacketSize) { |
| 2456 max_packet_size = kMaxPacketSize; |
| 2457 } |
| 2458 return max_packet_size; |
2454 } | 2459 } |
2455 | 2460 |
2456 void QuicConnection::SendMtuDiscoveryPacket(QuicByteCount target_mtu) { | 2461 void QuicConnection::SendMtuDiscoveryPacket(QuicByteCount target_mtu) { |
2457 // Currently, this limit is ensured by the caller. | 2462 // Currently, this limit is ensured by the caller. |
2458 DCHECK_EQ(target_mtu, GetLimitedMaxPacketSize(target_mtu)); | 2463 DCHECK_EQ(target_mtu, GetLimitedMaxPacketSize(target_mtu)); |
2459 | 2464 |
2460 // Send the probe. | 2465 // Send the probe. |
2461 packet_generator_.GenerateMtuDiscoveryPacket(target_mtu, nullptr); | 2466 packet_generator_.GenerateMtuDiscoveryPacket(target_mtu, nullptr); |
2462 } | 2467 } |
2463 | 2468 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 | 2590 |
2586 void QuicConnection::CheckIfApplicationLimited() { | 2591 void QuicConnection::CheckIfApplicationLimited() { |
2587 if (queued_packets_.empty() && | 2592 if (queued_packets_.empty() && |
2588 !sent_packet_manager_->HasPendingRetransmissions() && | 2593 !sent_packet_manager_->HasPendingRetransmissions() && |
2589 !visitor_->WillingAndAbleToWrite()) { | 2594 !visitor_->WillingAndAbleToWrite()) { |
2590 sent_packet_manager_->OnApplicationLimited(); | 2595 sent_packet_manager_->OnApplicationLimited(); |
2591 } | 2596 } |
2592 } | 2597 } |
2593 | 2598 |
2594 } // namespace net | 2599 } // namespace net |
OLD | NEW |