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/quic_connection.h" | 5 #include "net/quic/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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 if (last_packet_revived_) { | 900 if (last_packet_revived_) { |
901 received_packet_manager_.RecordPacketRevived( | 901 received_packet_manager_.RecordPacketRevived( |
902 last_header_.packet_sequence_number); | 902 last_header_.packet_sequence_number); |
903 } else { | 903 } else { |
904 received_packet_manager_.RecordPacketReceived( | 904 received_packet_manager_.RecordPacketReceived( |
905 last_size_, last_header_, time_of_last_received_packet_); | 905 last_size_, last_header_, time_of_last_received_packet_); |
906 } | 906 } |
907 | 907 |
908 if (!last_stream_frames_.empty()) { | 908 if (!last_stream_frames_.empty()) { |
909 visitor_->OnStreamFrames(last_stream_frames_); | 909 visitor_->OnStreamFrames(last_stream_frames_); |
| 910 if (!connected_ && !FLAGS_quic_stop_early) { |
| 911 return; |
| 912 } |
910 } | 913 } |
911 | 914 |
912 for (size_t i = 0; i < last_stream_frames_.size(); ++i) { | 915 for (size_t i = 0; i < last_stream_frames_.size(); ++i) { |
913 stats_.stream_bytes_received += | 916 stats_.stream_bytes_received += |
914 last_stream_frames_[i].data.TotalBufferSize(); | 917 last_stream_frames_[i].data.TotalBufferSize(); |
915 } | 918 } |
916 | |
917 // Process window updates, blocked, stream resets, acks, then congestion | 919 // Process window updates, blocked, stream resets, acks, then congestion |
918 // feedback. | 920 // feedback. |
919 if (!last_window_update_frames_.empty()) { | 921 if (!last_window_update_frames_.empty()) { |
920 visitor_->OnWindowUpdateFrames(last_window_update_frames_); | 922 visitor_->OnWindowUpdateFrames(last_window_update_frames_); |
| 923 if (!connected_ && !FLAGS_quic_stop_early) { |
| 924 return; |
| 925 } |
921 } | 926 } |
922 if (!last_blocked_frames_.empty()) { | 927 if (!last_blocked_frames_.empty()) { |
923 visitor_->OnBlockedFrames(last_blocked_frames_); | 928 visitor_->OnBlockedFrames(last_blocked_frames_); |
| 929 if (!connected_ && !FLAGS_quic_stop_early) { |
| 930 return; |
| 931 } |
924 } | 932 } |
925 for (size_t i = 0; i < last_goaway_frames_.size(); ++i) { | 933 for (size_t i = 0; i < last_goaway_frames_.size(); ++i) { |
926 visitor_->OnGoAway(last_goaway_frames_[i]); | 934 visitor_->OnGoAway(last_goaway_frames_[i]); |
| 935 if (!connected_ && !FLAGS_quic_stop_early) { |
| 936 return; |
| 937 } |
927 } | 938 } |
928 for (size_t i = 0; i < last_rst_frames_.size(); ++i) { | 939 for (size_t i = 0; i < last_rst_frames_.size(); ++i) { |
929 visitor_->OnRstStream(last_rst_frames_[i]); | 940 visitor_->OnRstStream(last_rst_frames_[i]); |
| 941 if (!connected_ && !FLAGS_quic_stop_early) { |
| 942 return; |
| 943 } |
930 } | 944 } |
931 for (size_t i = 0; i < last_ack_frames_.size(); ++i) { | 945 for (size_t i = 0; i < last_ack_frames_.size(); ++i) { |
932 ProcessAckFrame(last_ack_frames_[i]); | 946 ProcessAckFrame(last_ack_frames_[i]); |
| 947 if (!connected_ && !FLAGS_quic_stop_early) { |
| 948 return; |
| 949 } |
933 } | 950 } |
934 for (size_t i = 0; i < last_stop_waiting_frames_.size(); ++i) { | 951 for (size_t i = 0; i < last_stop_waiting_frames_.size(); ++i) { |
935 ProcessStopWaitingFrame(last_stop_waiting_frames_[i]); | 952 ProcessStopWaitingFrame(last_stop_waiting_frames_[i]); |
| 953 if (!connected_ && !FLAGS_quic_stop_early) { |
| 954 return; |
| 955 } |
936 } | 956 } |
937 if (!last_close_frames_.empty()) { | 957 if (!last_close_frames_.empty()) { |
938 CloseConnection(last_close_frames_[0].error_code, true); | 958 CloseConnection(last_close_frames_[0].error_code, true); |
939 DCHECK(!connected_); | 959 DCHECK(!connected_); |
| 960 if (!FLAGS_quic_stop_early) { |
| 961 return; |
| 962 } |
940 } | 963 } |
941 | 964 |
942 // If there are new missing packets to report, send an ack immediately. | 965 // If there are new missing packets to report, send an ack immediately. |
943 if (received_packet_manager_.HasNewMissingPackets()) { | 966 if (received_packet_manager_.HasNewMissingPackets()) { |
944 ack_queued_ = true; | 967 ack_queued_ = true; |
945 ack_alarm_->Cancel(); | 968 ack_alarm_->Cancel(); |
946 } | 969 } |
947 | 970 |
948 UpdateStopWaitingCount(); | 971 UpdateStopWaitingCount(); |
949 ClearLastFrames(); | 972 ClearLastFrames(); |
950 MaybeCloseIfTooManyOutstandingPackets(); | 973 MaybeCloseIfTooManyOutstandingPackets(); |
951 } | 974 } |
952 | 975 |
953 void QuicConnection::MaybeQueueAck() { | 976 void QuicConnection::MaybeQueueAck() { |
954 // If the incoming packet was missing, send an ack immediately. | 977 // If the incoming packet was missing, send an ack immediately. |
955 ack_queued_ = received_packet_manager_.IsMissing( | 978 ack_queued_ = received_packet_manager_.IsMissing( |
956 last_header_.packet_sequence_number); | 979 last_header_.packet_sequence_number); |
957 | 980 |
958 if (!ack_queued_ && ShouldLastPacketInstigateAck()) { | 981 if (!ack_queued_ && ShouldLastPacketInstigateAck()) { |
959 if (ack_alarm_->IsSet()) { | 982 if (ack_alarm_->IsSet()) { |
960 ack_queued_ = true; | 983 ack_queued_ = true; |
961 } else { | 984 } else { |
962 // Send an ack much more quickly for crypto handshake packets. | 985 ack_alarm_->Set( |
963 QuicTime::Delta delayed_ack_time = sent_packet_manager_.DelayedAckTime(); | 986 clock_->ApproximateNow().Add(sent_packet_manager_.DelayedAckTime())); |
964 ack_alarm_->Set(clock_->ApproximateNow().Add(delayed_ack_time)); | |
965 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK."; | 987 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK."; |
966 } | 988 } |
967 } | 989 } |
968 | 990 |
969 if (ack_queued_) { | 991 if (ack_queued_) { |
970 ack_alarm_->Cancel(); | 992 ack_alarm_->Cancel(); |
971 } | 993 } |
972 } | 994 } |
973 | 995 |
974 void QuicConnection::ClearLastFrames() { | 996 void QuicConnection::ClearLastFrames() { |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 } | 2156 } |
2135 for (const QuicFrame& frame : retransmittable_frames->frames()) { | 2157 for (const QuicFrame& frame : retransmittable_frames->frames()) { |
2136 if (frame.type == CONNECTION_CLOSE_FRAME) { | 2158 if (frame.type == CONNECTION_CLOSE_FRAME) { |
2137 return true; | 2159 return true; |
2138 } | 2160 } |
2139 } | 2161 } |
2140 return false; | 2162 return false; |
2141 } | 2163 } |
2142 | 2164 |
2143 } // namespace net | 2165 } // namespace net |
OLD | NEW |