| 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 17 matching lines...) Expand all Loading... |
| 28 #include "net/quic/core/quic_packet_generator.h" | 28 #include "net/quic/core/quic_packet_generator.h" |
| 29 #include "net/quic/core/quic_pending_retransmission.h" | 29 #include "net/quic/core/quic_pending_retransmission.h" |
| 30 #include "net/quic/core/quic_utils.h" | 30 #include "net/quic/core/quic_utils.h" |
| 31 #include "net/quic/platform/api/quic_bug_tracker.h" | 31 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 32 #include "net/quic/platform/api/quic_flag_utils.h" | 32 #include "net/quic/platform/api/quic_flag_utils.h" |
| 33 #include "net/quic/platform/api/quic_logging.h" | 33 #include "net/quic/platform/api/quic_logging.h" |
| 34 #include "net/quic/platform/api/quic_map_util.h" | 34 #include "net/quic/platform/api/quic_map_util.h" |
| 35 #include "net/quic/platform/api/quic_str_cat.h" | 35 #include "net/quic/platform/api/quic_str_cat.h" |
| 36 #include "net/quic/platform/api/quic_text_utils.h" | 36 #include "net/quic/platform/api/quic_text_utils.h" |
| 37 | 37 |
| 38 using base::StringPiece; | |
| 39 using std::string; | 38 using std::string; |
| 40 | 39 |
| 41 namespace net { | 40 namespace net { |
| 42 | 41 |
| 43 class QuicDecrypter; | 42 class QuicDecrypter; |
| 44 class QuicEncrypter; | 43 class QuicEncrypter; |
| 45 | 44 |
| 46 namespace { | 45 namespace { |
| 47 | 46 |
| 48 // The largest gap in packets we'll accept without closing the connection. | 47 // The largest gap in packets we'll accept without closing the connection. |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 DCHECK_LE(encrypted_length, kMaxPacketSize); | 1513 DCHECK_LE(encrypted_length, kMaxPacketSize); |
| 1515 DCHECK_LE(encrypted_length, packet_generator_.GetCurrentMaxPacketLength()); | 1514 DCHECK_LE(encrypted_length, packet_generator_.GetCurrentMaxPacketLength()); |
| 1516 QUIC_DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " | 1515 QUIC_DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " |
| 1517 << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA | 1516 << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA |
| 1518 ? "data bearing " | 1517 ? "data bearing " |
| 1519 : " ack only ") | 1518 : " ack only ") |
| 1520 << ", encryption level: " | 1519 << ", encryption level: " |
| 1521 << QuicUtils::EncryptionLevelToString(packet->encryption_level) | 1520 << QuicUtils::EncryptionLevelToString(packet->encryption_level) |
| 1522 << ", encrypted length:" << encrypted_length; | 1521 << ", encrypted length:" << encrypted_length; |
| 1523 QUIC_DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl | 1522 QUIC_DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl |
| 1524 << QuicTextUtils::HexDump( | 1523 << QuicTextUtils::HexDump(QuicStringPiece( |
| 1525 StringPiece(packet->encrypted_buffer, encrypted_length)); | 1524 packet->encrypted_buffer, encrypted_length)); |
| 1526 | 1525 |
| 1527 // Measure the RTT from before the write begins to avoid underestimating the | 1526 // Measure the RTT from before the write begins to avoid underestimating the |
| 1528 // min_rtt_, especially in cases where the thread blocks or gets swapped out | 1527 // min_rtt_, especially in cases where the thread blocks or gets swapped out |
| 1529 // during the WritePacket below. | 1528 // during the WritePacket below. |
| 1530 QuicTime packet_send_time = clock_->Now(); | 1529 QuicTime packet_send_time = clock_->Now(); |
| 1531 WriteResult result = writer_->WritePacket( | 1530 WriteResult result = writer_->WritePacket( |
| 1532 packet->encrypted_buffer, encrypted_length, self_address().host(), | 1531 packet->encrypted_buffer, encrypted_length, self_address().host(), |
| 1533 peer_address(), per_packet_options_); | 1532 peer_address(), per_packet_options_); |
| 1534 if (result.error_code == ERR_IO_PENDING) { | 1533 if (result.error_code == ERR_IO_PENDING) { |
| 1535 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); | 1534 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 // TODO(jri): Move these calls to OnPeerMigrationValidated. Rename | 2342 // TODO(jri): Move these calls to OnPeerMigrationValidated. Rename |
| 2344 // OnConnectionMigration methods to OnPeerMigration. | 2343 // OnConnectionMigration methods to OnPeerMigration. |
| 2345 visitor_->OnConnectionMigration(peer_migration_type); | 2344 visitor_->OnConnectionMigration(peer_migration_type); |
| 2346 sent_packet_manager_.OnConnectionMigration(peer_migration_type); | 2345 sent_packet_manager_.OnConnectionMigration(peer_migration_type); |
| 2347 } | 2346 } |
| 2348 | 2347 |
| 2349 bool QuicConnection::ack_frame_updated() const { | 2348 bool QuicConnection::ack_frame_updated() const { |
| 2350 return received_packet_manager_.ack_frame_updated(); | 2349 return received_packet_manager_.ack_frame_updated(); |
| 2351 } | 2350 } |
| 2352 | 2351 |
| 2353 StringPiece QuicConnection::GetCurrentPacket() { | 2352 QuicStringPiece QuicConnection::GetCurrentPacket() { |
| 2354 if (current_packet_data_ == nullptr) { | 2353 if (current_packet_data_ == nullptr) { |
| 2355 return StringPiece(); | 2354 return QuicStringPiece(); |
| 2356 } | 2355 } |
| 2357 return StringPiece(current_packet_data_, last_size_); | 2356 return QuicStringPiece(current_packet_data_, last_size_); |
| 2358 } | 2357 } |
| 2359 | 2358 |
| 2360 bool QuicConnection::MaybeConsiderAsMemoryCorruption( | 2359 bool QuicConnection::MaybeConsiderAsMemoryCorruption( |
| 2361 const QuicStreamFrame& frame) { | 2360 const QuicStreamFrame& frame) { |
| 2362 if (frame.stream_id == kCryptoStreamId || | 2361 if (frame.stream_id == kCryptoStreamId || |
| 2363 last_decrypted_packet_level_ != ENCRYPTION_NONE) { | 2362 last_decrypted_packet_level_ != ENCRYPTION_NONE) { |
| 2364 return false; | 2363 return false; |
| 2365 } | 2364 } |
| 2366 | 2365 |
| 2367 if (perspective_ == Perspective::IS_SERVER && | 2366 if (perspective_ == Perspective::IS_SERVER && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 | 2401 |
| 2403 void QuicConnection::CheckIfApplicationLimited() { | 2402 void QuicConnection::CheckIfApplicationLimited() { |
| 2404 if (queued_packets_.empty() && | 2403 if (queued_packets_.empty() && |
| 2405 !sent_packet_manager_.HasPendingRetransmissions() && | 2404 !sent_packet_manager_.HasPendingRetransmissions() && |
| 2406 !visitor_->WillingAndAbleToWrite()) { | 2405 !visitor_->WillingAndAbleToWrite()) { |
| 2407 sent_packet_manager_.OnApplicationLimited(); | 2406 sent_packet_manager_.OnApplicationLimited(); |
| 2408 } | 2407 } |
| 2409 } | 2408 } |
| 2410 | 2409 |
| 2411 } // namespace net | 2410 } // namespace net |
| OLD | NEW |