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

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

Issue 1437023002: Landing Recent QUIC changes until 2015-11-09 20:32 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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_connection.h ('k') | net/quic/quic_connection_logger.h » ('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 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } 1155 }
1156 1156
1157 void QuicConnection::SendRstStream(QuicStreamId id, 1157 void QuicConnection::SendRstStream(QuicStreamId id,
1158 QuicRstStreamErrorCode error, 1158 QuicRstStreamErrorCode error,
1159 QuicStreamOffset bytes_written) { 1159 QuicStreamOffset bytes_written) {
1160 // Opportunistically bundle an ack with this outgoing packet. 1160 // Opportunistically bundle an ack with this outgoing packet.
1161 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); 1161 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK);
1162 packet_generator_.AddControlFrame(QuicFrame(new QuicRstStreamFrame( 1162 packet_generator_.AddControlFrame(QuicFrame(new QuicRstStreamFrame(
1163 id, AdjustErrorForVersion(error, version()), bytes_written))); 1163 id, AdjustErrorForVersion(error, version()), bytes_written)));
1164 1164
1165 if (error == QUIC_STREAM_NO_ERROR && version() > QUIC_VERSION_28) {
1166 // All data for streams which are reset with QUIC_STREAM_NO_ERROR must
1167 // be received by the peer.
1168 return;
1169 }
1170
1165 sent_packet_manager_.CancelRetransmissionsForStream(id); 1171 sent_packet_manager_.CancelRetransmissionsForStream(id);
1166 // Remove all queued packets which only contain data for the reset stream. 1172 // Remove all queued packets which only contain data for the reset stream.
1167 QueuedPacketList::iterator packet_iterator = queued_packets_.begin(); 1173 QueuedPacketList::iterator packet_iterator = queued_packets_.begin();
1168 while (packet_iterator != queued_packets_.end()) { 1174 while (packet_iterator != queued_packets_.end()) {
1169 RetransmittableFrames* retransmittable_frames = 1175 RetransmittableFrames* retransmittable_frames =
1170 packet_iterator->serialized_packet.retransmittable_frames; 1176 packet_iterator->serialized_packet.retransmittable_frames;
1171 if (!retransmittable_frames) { 1177 if (!retransmittable_frames) {
1172 ++packet_iterator; 1178 ++packet_iterator;
1173 continue; 1179 continue;
1174 } 1180 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 IPEndPoint old_peer_address = peer_address_; 1362 IPEndPoint old_peer_address = peer_address_;
1357 peer_address_ = IPEndPoint( 1363 peer_address_ = IPEndPoint(
1358 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(), 1364 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(),
1359 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port()); 1365 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port());
1360 1366
1361 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " 1367 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from "
1362 << old_peer_address.ToString() << " to " 1368 << old_peer_address.ToString() << " to "
1363 << peer_address_.ToString() << ", migrating connection."; 1369 << peer_address_.ToString() << ", migrating connection.";
1364 1370
1365 visitor_->OnConnectionMigration(); 1371 visitor_->OnConnectionMigration();
1372 sent_packet_manager_.OnConnectionMigration(type);
1366 } 1373 }
1367 1374
1368 time_of_last_received_packet_ = clock_->Now(); 1375 time_of_last_received_packet_ = clock_->Now();
1369 DVLOG(1) << ENDPOINT << "time of last received packet: " 1376 DVLOG(1) << ENDPOINT << "time of last received packet: "
1370 << time_of_last_received_packet_.ToDebuggingValue(); 1377 << time_of_last_received_packet_.ToDebuggingValue();
1371 1378
1372 if (last_size_ > largest_received_packet_size_) { 1379 if (last_size_ > largest_received_packet_size_) {
1373 largest_received_packet_size_ = last_size_; 1380 largest_received_packet_size_ = last_size_;
1374 } 1381 }
1375 1382
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { 1467 bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) {
1461 if (!connected_) { 1468 if (!connected_) {
1462 return false; 1469 return false;
1463 } 1470 }
1464 1471
1465 if (writer_->IsWriteBlocked()) { 1472 if (writer_->IsWriteBlocked()) {
1466 visitor_->OnWriteBlocked(); 1473 visitor_->OnWriteBlocked();
1467 return false; 1474 return false;
1468 } 1475 }
1469 1476
1477 // If the send alarm is set, wait for it to fire.
1478 if (FLAGS_respect_send_alarm && send_alarm_->IsSet()) {
1479 return false;
1480 }
1481
1470 QuicTime now = clock_->Now(); 1482 QuicTime now = clock_->Now();
1471 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend( 1483 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend(
1472 now, retransmittable); 1484 now, retransmittable);
1473 if (delay.IsInfinite()) { 1485 if (delay.IsInfinite()) {
1474 send_alarm_->Cancel(); 1486 send_alarm_->Cancel();
1475 return false; 1487 return false;
1476 } 1488 }
1477 1489
1478 // If the scheduler requires a delay, then we can not send this packet now. 1490 // If the scheduler requires a delay, then we can not send this packet now.
1479 if (!delay.IsZero()) { 1491 if (!delay.IsZero()) {
1480 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); 1492 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1));
1481 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() 1493 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds()
1482 << "ms"; 1494 << "ms";
1483 return false; 1495 return false;
1484 } 1496 }
1485 send_alarm_->Cancel(); 1497 if (!FLAGS_respect_send_alarm) {
1498 send_alarm_->Cancel();
1499 }
1486 return true; 1500 return true;
1487 } 1501 }
1488 1502
1489 bool QuicConnection::WritePacket(QueuedPacket* packet) { 1503 bool QuicConnection::WritePacket(QueuedPacket* packet) {
1490 if (!WritePacketInner(packet)) { 1504 if (!WritePacketInner(packet)) {
1491 return false; 1505 return false;
1492 } 1506 }
1493 delete packet->serialized_packet.retransmittable_frames; 1507 delete packet->serialized_packet.retransmittable_frames;
1494 delete packet->serialized_packet.packet; 1508 delete packet->serialized_packet.packet;
1495 packet->serialized_packet.retransmittable_frames = nullptr; 1509 packet->serialized_packet.retransmittable_frames = nullptr;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 // duplicate packet being sent. The helper must call OnCanWrite 1585 // duplicate packet being sent. The helper must call OnCanWrite
1572 // when the write completes, and OnWriteError if an error occurs. 1586 // when the write completes, and OnWriteError if an error occurs.
1573 if (!writer_->IsWriteBlockedDataBuffered()) { 1587 if (!writer_->IsWriteBlockedDataBuffered()) {
1574 return false; 1588 return false;
1575 } 1589 }
1576 } 1590 }
1577 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { 1591 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) {
1578 // Pass the write result to the visitor. 1592 // Pass the write result to the visitor.
1579 debug_visitor_->OnPacketSent( 1593 debug_visitor_->OnPacketSent(
1580 packet->serialized_packet, packet->original_packet_number, 1594 packet->serialized_packet, packet->original_packet_number,
1581 packet->encryption_level, packet->transmission_type, *encrypted, 1595 packet->encryption_level, packet->transmission_type,
1582 packet_send_time); 1596 encrypted->length(), packet_send_time);
1583 } 1597 }
1584 if (packet->transmission_type == NOT_RETRANSMISSION) { 1598 if (packet->transmission_type == NOT_RETRANSMISSION) {
1585 time_of_last_sent_new_packet_ = packet_send_time; 1599 time_of_last_sent_new_packet_ = packet_send_time;
1586 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && 1600 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA &&
1587 last_send_for_timeout_ <= time_of_last_received_packet_) { 1601 last_send_for_timeout_ <= time_of_last_received_packet_) {
1588 last_send_for_timeout_ = packet_send_time; 1602 last_send_for_timeout_ = packet_send_time;
1589 } 1603 }
1590 } 1604 }
1591 SetPingAlarm(); 1605 SetPingAlarm();
1592 MaybeSetFecAlarm(packet_number); 1606 MaybeSetFecAlarm(packet_number);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 packet_generator_.AddControlFrame(QuicFrame(frame)); 1986 packet_generator_.AddControlFrame(QuicFrame(frame));
1973 packet_generator_.FlushAllQueuedFrames(); 1987 packet_generator_.FlushAllQueuedFrames();
1974 } 1988 }
1975 1989
1976 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { 1990 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) {
1977 if (!connected_) { 1991 if (!connected_) {
1978 DVLOG(1) << "Connection is already closed."; 1992 DVLOG(1) << "Connection is already closed.";
1979 return; 1993 return;
1980 } 1994 }
1981 connected_ = false; 1995 connected_ = false;
1996 DCHECK(visitor_ != nullptr);
1997 visitor_->OnConnectionClosed(error, from_peer);
1982 if (debug_visitor_ != nullptr) { 1998 if (debug_visitor_ != nullptr) {
1983 debug_visitor_->OnConnectionClosed(error, from_peer); 1999 debug_visitor_->OnConnectionClosed(error, from_peer);
1984 } 2000 }
1985 DCHECK(visitor_ != nullptr);
1986 visitor_->OnConnectionClosed(error, from_peer);
1987 // Cancel the alarms so they don't trigger any action now that the 2001 // Cancel the alarms so they don't trigger any action now that the
1988 // connection is closed. 2002 // connection is closed.
1989 ack_alarm_->Cancel(); 2003 ack_alarm_->Cancel();
1990 ping_alarm_->Cancel(); 2004 ping_alarm_->Cancel();
1991 fec_alarm_->Cancel(); 2005 fec_alarm_->Cancel();
1992 resume_writes_alarm_->Cancel(); 2006 resume_writes_alarm_->Cancel();
1993 retransmission_alarm_->Cancel(); 2007 retransmission_alarm_->Cancel();
1994 send_alarm_->Cancel(); 2008 send_alarm_->Cancel();
1995 timeout_alarm_->Cancel(); 2009 timeout_alarm_->Cancel();
1996 mtu_discovery_alarm_->Cancel(); 2010 mtu_discovery_alarm_->Cancel();
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; 2351 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1;
2338 ++mtu_probe_count_; 2352 ++mtu_probe_count_;
2339 2353
2340 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; 2354 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_;
2341 SendMtuDiscoveryPacket(mtu_discovery_target_); 2355 SendMtuDiscoveryPacket(mtu_discovery_target_);
2342 2356
2343 DCHECK(!mtu_discovery_alarm_->IsSet()); 2357 DCHECK(!mtu_discovery_alarm_->IsSet());
2344 } 2358 }
2345 2359
2346 } // namespace net 2360 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698