Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: net/quic/quic_connection.cc

Issue 2158263003: Landing Recent QUIC changes until 7/18/2016 11:21:53 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Running flag flipping script and rebase to master Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_alarm.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 } 1084 }
1085 1085
1086 // If there are new missing packets to report, send an ack immediately. 1086 // If there are new missing packets to report, send an ack immediately.
1087 if (received_packet_manager_.HasNewMissingPackets()) { 1087 if (received_packet_manager_.HasNewMissingPackets()) {
1088 if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) { 1088 if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) {
1089 // Wait the minimum of an eighth min_rtt and the existing ack time. 1089 // Wait the minimum of an eighth min_rtt and the existing ack time.
1090 QuicTime ack_time = 1090 QuicTime ack_time =
1091 clock_->ApproximateNow() + 1091 clock_->ApproximateNow() +
1092 0.125 * sent_packet_manager_->GetRttStats()->min_rtt(); 1092 0.125 * sent_packet_manager_->GetRttStats()->min_rtt();
1093 if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) { 1093 if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) {
1094 ack_alarm_->Cancel(); 1094 ack_alarm_->Update(ack_time, QuicTime::Delta::Zero());
1095 ack_alarm_->Set(ack_time);
1096 } 1095 }
1097 } else { 1096 } else {
1098 ack_queued_ = true; 1097 ack_queued_ = true;
1099 } 1098 }
1100 } 1099 }
1101 } 1100 }
1102 1101
1103 if (ack_queued_) { 1102 if (ack_queued_) {
1104 ack_alarm_->Cancel(); 1103 ack_alarm_->Cancel();
1105 } 1104 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 return sent_packet_manager_->GetLeastUnacked(path_id); 1150 return sent_packet_manager_->GetLeastUnacked(path_id);
1152 } 1151 }
1153 1152
1154 void QuicConnection::MaybeSendInResponseToPacket() { 1153 void QuicConnection::MaybeSendInResponseToPacket() {
1155 if (!connected_) { 1154 if (!connected_) {
1156 return; 1155 return;
1157 } 1156 }
1158 // Now that we have received an ack, we might be able to send packets which 1157 // Now that we have received an ack, we might be able to send packets which
1159 // are queued locally, or drain streams which are blocked. 1158 // are queued locally, or drain streams which are blocked.
1160 if (defer_send_in_response_to_packets_) { 1159 if (defer_send_in_response_to_packets_) {
1161 send_alarm_->Cancel(); 1160 send_alarm_->Update(clock_->ApproximateNow(), QuicTime::Delta::Zero());
1162 send_alarm_->Set(clock_->ApproximateNow());
1163 } else { 1161 } else {
1164 WriteAndBundleAcksIfNotBlocked(); 1162 WriteAndBundleAcksIfNotBlocked();
1165 } 1163 }
1166 } 1164 }
1167 1165
1168 void QuicConnection::SendVersionNegotiationPacket() { 1166 void QuicConnection::SendVersionNegotiationPacket() {
1169 // TODO(alyssar): implement zero server state negotiation. 1167 // TODO(alyssar): implement zero server state negotiation.
1170 pending_version_negotiation_packet_ = true; 1168 pending_version_negotiation_packet_ = true;
1171 if (writer_->IsWriteBlocked()) { 1169 if (writer_->IsWriteBlocked()) {
1172 visitor_->OnWriteBlocked(); 1170 visitor_->OnWriteBlocked();
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 SetMaxPacketLength(packet_size); 1825 SetMaxPacketLength(packet_size);
1828 } 1826 }
1829 } 1827 }
1830 1828
1831 void QuicConnection::OnHandshakeComplete() { 1829 void QuicConnection::OnHandshakeComplete() {
1832 sent_packet_manager_->SetHandshakeConfirmed(); 1830 sent_packet_manager_->SetHandshakeConfirmed();
1833 // The client should immediately ack the SHLO to confirm the handshake is 1831 // The client should immediately ack the SHLO to confirm the handshake is
1834 // complete with the server. 1832 // complete with the server.
1835 if (perspective_ == Perspective::IS_CLIENT && !ack_queued_ && 1833 if (perspective_ == Perspective::IS_CLIENT && !ack_queued_ &&
1836 ack_frame_updated()) { 1834 ack_frame_updated()) {
1837 ack_alarm_->Cancel(); 1835 ack_alarm_->Update(clock_->ApproximateNow(), QuicTime::Delta::Zero());
1838 ack_alarm_->Set(clock_->ApproximateNow());
1839 } 1836 }
1840 } 1837 }
1841 1838
1842 void QuicConnection::SendOrQueuePacket(SerializedPacket* packet) { 1839 void QuicConnection::SendOrQueuePacket(SerializedPacket* packet) {
1843 // The caller of this function is responsible for checking CanWrite(). 1840 // The caller of this function is responsible for checking CanWrite().
1844 if (packet->encrypted_buffer == nullptr) { 1841 if (packet->encrypted_buffer == nullptr) {
1845 QUIC_BUG << "packet.encrypted_buffer == nullptr in to SendOrQueuePacket"; 1842 QUIC_BUG << "packet.encrypted_buffer == nullptr in to SendOrQueuePacket";
1846 return; 1843 return;
1847 } 1844 }
1848 if (version() <= QUIC_VERSION_33) { 1845 if (version() <= QUIC_VERSION_33) {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 void QuicConnection::SetTimeoutAlarm() { 2194 void QuicConnection::SetTimeoutAlarm() {
2198 QuicTime time_of_last_packet = 2195 QuicTime time_of_last_packet =
2199 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); 2196 max(time_of_last_received_packet_, time_of_last_sent_new_packet_);
2200 2197
2201 QuicTime deadline = time_of_last_packet + idle_network_timeout_; 2198 QuicTime deadline = time_of_last_packet + idle_network_timeout_;
2202 if (!handshake_timeout_.IsInfinite()) { 2199 if (!handshake_timeout_.IsInfinite()) {
2203 deadline = 2200 deadline =
2204 min(deadline, stats_.connection_creation_time + handshake_timeout_); 2201 min(deadline, stats_.connection_creation_time + handshake_timeout_);
2205 } 2202 }
2206 2203
2207 timeout_alarm_->Cancel(); 2204 timeout_alarm_->Update(deadline, QuicTime::Delta::Zero());
2208 timeout_alarm_->Set(deadline);
2209 } 2205 }
2210 2206
2211 void QuicConnection::SetPingAlarm() { 2207 void QuicConnection::SetPingAlarm() {
2212 if (perspective_ == Perspective::IS_SERVER) { 2208 if (perspective_ == Perspective::IS_SERVER) {
2213 // Only clients send pings. 2209 // Only clients send pings.
2214 return; 2210 return;
2215 } 2211 }
2216 if (!visitor_->HasOpenDynamicStreams()) { 2212 if (!visitor_->HasOpenDynamicStreams()) {
2217 ping_alarm_->Cancel(); 2213 ping_alarm_->Cancel();
2218 // Don't send a ping unless there are open streams. 2214 // Don't send a ping unless there are open streams.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 // the sender and a signaling mechanism -- if the sender uses a 2509 // the sender and a signaling mechanism -- if the sender uses a
2514 // different MinRTO, we may get spurious retransmissions. May not have 2510 // different MinRTO, we may get spurious retransmissions. May not have
2515 // any benefits, but if the delayed ack becomes a significant source 2511 // any benefits, but if the delayed ack becomes a significant source
2516 // of (likely, tail) latency, then consider such a mechanism. 2512 // of (likely, tail) latency, then consider such a mechanism.
2517 const QuicTime::Delta QuicConnection::DelayedAckTime() { 2513 const QuicTime::Delta QuicConnection::DelayedAckTime() {
2518 return QuicTime::Delta::FromMilliseconds( 2514 return QuicTime::Delta::FromMilliseconds(
2519 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); 2515 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2));
2520 } 2516 }
2521 2517
2522 } // namespace net 2518 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_alarm.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698