| 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 return connected_; | 901 return connected_; |
| 902 } | 902 } |
| 903 | 903 |
| 904 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { | 904 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { |
| 905 DCHECK(connected_); | 905 DCHECK(connected_); |
| 906 if (debug_visitor_ != nullptr) { | 906 if (debug_visitor_ != nullptr) { |
| 907 debug_visitor_->OnPathCloseFrame(frame); | 907 debug_visitor_->OnPathCloseFrame(frame); |
| 908 } | 908 } |
| 909 QUIC_DLOG(INFO) << ENDPOINT | 909 QUIC_DLOG(INFO) << ENDPOINT |
| 910 << "PATH_CLOSE_FRAME received for path: " << frame.path_id; | 910 << "PATH_CLOSE_FRAME received for path: " << frame.path_id; |
| 911 OnPathClosed(frame.path_id); | |
| 912 return connected_; | 911 return connected_; |
| 913 } | 912 } |
| 914 | 913 |
| 915 void QuicConnection::OnPacketComplete() { | 914 void QuicConnection::OnPacketComplete() { |
| 916 // Don't do anything if this packet closed the connection. | 915 // Don't do anything if this packet closed the connection. |
| 917 if (!connected_) { | 916 if (!connected_) { |
| 918 ClearLastFrames(); | 917 ClearLastFrames(); |
| 919 return; | 918 return; |
| 920 } | 919 } |
| 921 | 920 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 // Opportunistically bundle an ack with this outgoing packet. | 1136 // Opportunistically bundle an ack with this outgoing packet. |
| 1138 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1137 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
| 1139 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id))); | 1138 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id))); |
| 1140 stats_.blocked_frames_sent++; | 1139 stats_.blocked_frames_sent++; |
| 1141 } | 1140 } |
| 1142 | 1141 |
| 1143 void QuicConnection::SendPathClose(QuicPathId path_id) { | 1142 void QuicConnection::SendPathClose(QuicPathId path_id) { |
| 1144 // Opportunistically bundle an ack with this outgoing packet. | 1143 // Opportunistically bundle an ack with this outgoing packet. |
| 1145 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1144 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
| 1146 packet_generator_.AddControlFrame(QuicFrame(new QuicPathCloseFrame(path_id))); | 1145 packet_generator_.AddControlFrame(QuicFrame(new QuicPathCloseFrame(path_id))); |
| 1147 OnPathClosed(path_id); | |
| 1148 } | 1146 } |
| 1149 | 1147 |
| 1150 const QuicConnectionStats& QuicConnection::GetStats() { | 1148 const QuicConnectionStats& QuicConnection::GetStats() { |
| 1151 const RttStats* rtt_stats = sent_packet_manager_.GetRttStats(); | 1149 const RttStats* rtt_stats = sent_packet_manager_.GetRttStats(); |
| 1152 | 1150 |
| 1153 // Update rtt and estimated bandwidth. | 1151 // Update rtt and estimated bandwidth. |
| 1154 QuicTime::Delta min_rtt = rtt_stats->min_rtt(); | 1152 QuicTime::Delta min_rtt = rtt_stats->min_rtt(); |
| 1155 if (min_rtt.IsZero()) { | 1153 if (min_rtt.IsZero()) { |
| 1156 // If min RTT has not been set, use initial RTT instead. | 1154 // If min RTT has not been set, use initial RTT instead. |
| 1157 min_rtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()); | 1155 min_rtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()); |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 sent_packet_manager_.GetLargestSentPacket(); | 2328 sent_packet_manager_.GetLargestSentPacket(); |
| 2331 peer_address_ = last_packet_source_address_; | 2329 peer_address_ = last_packet_source_address_; |
| 2332 active_peer_migration_type_ = peer_migration_type; | 2330 active_peer_migration_type_ = peer_migration_type; |
| 2333 | 2331 |
| 2334 // TODO(jri): Move these calls to OnPeerMigrationValidated. Rename | 2332 // TODO(jri): Move these calls to OnPeerMigrationValidated. Rename |
| 2335 // OnConnectionMigration methods to OnPeerMigration. | 2333 // OnConnectionMigration methods to OnPeerMigration. |
| 2336 visitor_->OnConnectionMigration(peer_migration_type); | 2334 visitor_->OnConnectionMigration(peer_migration_type); |
| 2337 sent_packet_manager_.OnConnectionMigration(peer_migration_type); | 2335 sent_packet_manager_.OnConnectionMigration(peer_migration_type); |
| 2338 } | 2336 } |
| 2339 | 2337 |
| 2340 void QuicConnection::OnPathClosed(QuicPathId path_id) { | |
| 2341 // Stop receiving packets on this path. | |
| 2342 framer_.OnPathClosed(path_id); | |
| 2343 } | |
| 2344 | |
| 2345 bool QuicConnection::ack_frame_updated() const { | 2338 bool QuicConnection::ack_frame_updated() const { |
| 2346 return received_packet_manager_.ack_frame_updated(); | 2339 return received_packet_manager_.ack_frame_updated(); |
| 2347 } | 2340 } |
| 2348 | 2341 |
| 2349 StringPiece QuicConnection::GetCurrentPacket() { | 2342 StringPiece QuicConnection::GetCurrentPacket() { |
| 2350 if (current_packet_data_ == nullptr) { | 2343 if (current_packet_data_ == nullptr) { |
| 2351 return StringPiece(); | 2344 return StringPiece(); |
| 2352 } | 2345 } |
| 2353 return StringPiece(current_packet_data_, last_size_); | 2346 return StringPiece(current_packet_data_, last_size_); |
| 2354 } | 2347 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2398 | 2391 |
| 2399 void QuicConnection::CheckIfApplicationLimited() { | 2392 void QuicConnection::CheckIfApplicationLimited() { |
| 2400 if (queued_packets_.empty() && | 2393 if (queued_packets_.empty() && |
| 2401 !sent_packet_manager_.HasPendingRetransmissions() && | 2394 !sent_packet_manager_.HasPendingRetransmissions() && |
| 2402 !visitor_->WillingAndAbleToWrite()) { | 2395 !visitor_->WillingAndAbleToWrite()) { |
| 2403 sent_packet_manager_.OnApplicationLimited(); | 2396 sent_packet_manager_.OnApplicationLimited(); |
| 2404 } | 2397 } |
| 2405 } | 2398 } |
| 2406 | 2399 |
| 2407 } // namespace net | 2400 } // namespace net |
| OLD | NEW |