| 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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 return; | 1051 return; |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 pending_version_negotiation_packet_ = false; | 1054 pending_version_negotiation_packet_ = false; |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 QuicConsumedData QuicConnection::SendStreamData( | 1057 QuicConsumedData QuicConnection::SendStreamData( |
| 1058 QuicStreamId id, | 1058 QuicStreamId id, |
| 1059 QuicIOVector iov, | 1059 QuicIOVector iov, |
| 1060 QuicStreamOffset offset, | 1060 QuicStreamOffset offset, |
| 1061 bool fin, | 1061 StreamSendingState state, |
| 1062 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { | 1062 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { |
| 1063 if (!fin && iov.total_length == 0) { | 1063 if (state == NO_FIN && iov.total_length == 0) { |
| 1064 QUIC_BUG << "Attempt to send empty stream frame"; | 1064 QUIC_BUG << "Attempt to send empty stream frame"; |
| 1065 return QuicConsumedData(0, false); | 1065 return QuicConsumedData(0, false); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 // Opportunistically bundle an ack with every outgoing packet. | 1068 // Opportunistically bundle an ack with every outgoing packet. |
| 1069 // Particularly, we want to bundle with handshake packets since we don't know | 1069 // Particularly, we want to bundle with handshake packets since we don't know |
| 1070 // which decrypter will be used on an ack packet following a handshake | 1070 // which decrypter will be used on an ack packet following a handshake |
| 1071 // packet (a handshake packet from client to server could result in a REJ or a | 1071 // packet (a handshake packet from client to server could result in a REJ or a |
| 1072 // SHLO from the server, leading to two different decrypters at the server.) | 1072 // SHLO from the server, leading to two different decrypters at the server.) |
| 1073 ScopedRetransmissionScheduler alarm_delayer(this); | 1073 ScopedRetransmissionScheduler alarm_delayer(this); |
| 1074 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1074 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
| 1075 // 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 |
| 1076 // standard buffer and don't need padding. | 1076 // standard buffer and don't need padding. |
| 1077 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() && | 1077 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() && |
| 1078 iov.total_length > kMaxPacketSize) { | 1078 iov.total_length > kMaxPacketSize && state != FIN_AND_PADDING) { |
| 1079 // Use the fast path to send full data packets. | 1079 // Use the fast path to send full data packets. |
| 1080 return packet_generator_.ConsumeDataFastPath(id, iov, offset, fin, | 1080 return packet_generator_.ConsumeDataFastPath( |
| 1081 std::move(ack_listener)); | 1081 id, iov, offset, state != NO_FIN, std::move(ack_listener)); |
| 1082 } | 1082 } |
| 1083 return packet_generator_.ConsumeData(id, iov, offset, fin ? FIN : NO_FIN, | 1083 return packet_generator_.ConsumeData(id, iov, offset, state, |
| 1084 std::move(ack_listener)); | 1084 std::move(ack_listener)); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 void QuicConnection::SendRstStream(QuicStreamId id, | 1087 void QuicConnection::SendRstStream(QuicStreamId id, |
| 1088 QuicRstStreamErrorCode error, | 1088 QuicRstStreamErrorCode error, |
| 1089 QuicStreamOffset bytes_written) { | 1089 QuicStreamOffset bytes_written) { |
| 1090 // Opportunistically bundle an ack with this outgoing packet. | 1090 // Opportunistically bundle an ack with this outgoing packet. |
| 1091 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1091 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
| 1092 packet_generator_.AddControlFrame( | 1092 packet_generator_.AddControlFrame( |
| 1093 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... |
| 2388 | 2388 |
| 2389 void QuicConnection::CheckIfApplicationLimited() { | 2389 void QuicConnection::CheckIfApplicationLimited() { |
| 2390 if (queued_packets_.empty() && | 2390 if (queued_packets_.empty() && |
| 2391 !sent_packet_manager_.HasPendingRetransmissions() && | 2391 !sent_packet_manager_.HasPendingRetransmissions() && |
| 2392 !visitor_->WillingAndAbleToWrite()) { | 2392 !visitor_->WillingAndAbleToWrite()) { |
| 2393 sent_packet_manager_.OnApplicationLimited(); | 2393 sent_packet_manager_.OnApplicationLimited(); |
| 2394 } | 2394 } |
| 2395 } | 2395 } |
| 2396 | 2396 |
| 2397 } // namespace net | 2397 } // namespace net |
| OLD | NEW |