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

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

Issue 23597045: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged QuicPriority to RequestPriority changes Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_helper_test.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "net/quic/crypto/quic_decrypter.h" 11 #include "net/quic/crypto/quic_decrypter.h"
12 #include "net/quic/crypto/quic_encrypter.h" 12 #include "net/quic/crypto/quic_encrypter.h"
13 #include "net/quic/quic_utils.h" 13 #include "net/quic/quic_utils.h"
14 14
15 using base::hash_map; 15 using base::hash_map;
16 using base::hash_set; 16 using base::hash_set;
17 using base::StringPiece; 17 using base::StringPiece;
18 using std::list; 18 using std::list;
19 using std::make_pair; 19 using std::make_pair;
20 using std::min; 20 using std::min;
21 using std::max; 21 using std::max;
22 using std::numeric_limits;
22 using std::vector; 23 using std::vector;
23 using std::set; 24 using std::set;
24 using std::string; 25 using std::string;
25 26
26 namespace net { 27 namespace net {
27 namespace { 28 namespace {
28 29
29 // The largest gap in packets we'll accept without closing the connection. 30 // The largest gap in packets we'll accept without closing the connection.
30 // This will likely have to be tuned. 31 // This will likely have to be tuned.
31 const QuicPacketSequenceNumber kMaxPacketGap = 5000; 32 const QuicPacketSequenceNumber kMaxPacketGap = 5000;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 case NEGOTIATED_VERSION: 276 case NEGOTIATED_VERSION:
276 // Might be old packets that were sent by the client before the version 277 // Might be old packets that were sent by the client before the version
277 // was negotiated. Drop these. 278 // was negotiated. Drop these.
278 return false; 279 return false;
279 280
280 default: 281 default:
281 DCHECK(false); 282 DCHECK(false);
282 } 283 }
283 284
284 version_negotiation_state_ = NEGOTIATED_VERSION; 285 version_negotiation_state_ = NEGOTIATED_VERSION;
286 visitor_->OnSuccessfulVersionNegotiation(received_version);
285 287
286 // Store the new version. 288 // Store the new version.
287 framer_.set_version(received_version); 289 framer_.set_version(received_version);
288 290
289 // TODO(satyamshekhar): Store the sequence number of this packet and close the 291 // TODO(satyamshekhar): Store the sequence number of this packet and close the
290 // connection if we ever received a packet with incorrect version and whose 292 // connection if we ever received a packet with incorrect version and whose
291 // sequence number is greater. 293 // sequence number is greater.
292 return true; 294 return true;
293 } 295 }
294 296
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 DLOG(WARNING) << ENDPOINT << "Got packet without version flag before " 375 DLOG(WARNING) << ENDPOINT << "Got packet without version flag before "
374 << "version negotiated."; 376 << "version negotiated.";
375 // Packets should have the version flag till version negotiation is 377 // Packets should have the version flag till version negotiation is
376 // done. 378 // done.
377 CloseConnection(QUIC_INVALID_VERSION, false); 379 CloseConnection(QUIC_INVALID_VERSION, false);
378 return false; 380 return false;
379 } else { 381 } else {
380 DCHECK_EQ(1u, header.public_header.versions.size()); 382 DCHECK_EQ(1u, header.public_header.versions.size());
381 DCHECK_EQ(header.public_header.versions[0], version()); 383 DCHECK_EQ(header.public_header.versions[0], version());
382 version_negotiation_state_ = NEGOTIATED_VERSION; 384 version_negotiation_state_ = NEGOTIATED_VERSION;
385 visitor_->OnSuccessfulVersionNegotiation(version());
383 } 386 }
384 } else { 387 } else {
385 DCHECK(!header.public_header.version_flag); 388 DCHECK(!header.public_header.version_flag);
386 // If the client gets a packet without the version flag from the server 389 // If the client gets a packet without the version flag from the server
387 // it should stop sending version since the version negotiation is done. 390 // it should stop sending version since the version negotiation is done.
388 packet_creator_.StopSendingVersion(); 391 packet_creator_.StopSendingVersion();
389 version_negotiation_state_ = NEGOTIATED_VERSION; 392 version_negotiation_state_ = NEGOTIATED_VERSION;
393 visitor_->OnSuccessfulVersionNegotiation(version());
390 } 394 }
391 } 395 }
392 396
393 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); 397 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_);
394 398
395 --stats_.packets_dropped; 399 --stats_.packets_dropped;
396 DVLOG(1) << ENDPOINT << "Received packet header: " << header; 400 DVLOG(1) << ENDPOINT << "Received packet header: " << header;
397 last_header_ = header; 401 last_header_ = header;
398 DCHECK(connected_); 402 DCHECK(connected_);
399 return true; 403 return true;
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 packet_generator_.StartBatchOperations(); 778 packet_generator_.StartBatchOperations();
775 779
776 if (last_packet_should_instigate_ack || 780 if (last_packet_should_instigate_ack ||
777 !g_acks_do_not_instigate_acks) { 781 !g_acks_do_not_instigate_acks) {
778 if (send_ack_in_response_to_packet_) { 782 if (send_ack_in_response_to_packet_) {
779 SendAck(); 783 SendAck();
780 } else if (last_packet_should_instigate_ack) { 784 } else if (last_packet_should_instigate_ack) {
781 // Set the ack alarm for when any retransmittable frame is received. 785 // Set the ack alarm for when any retransmittable frame is received.
782 if (!ack_alarm_->IsSet()) { 786 if (!ack_alarm_->IsSet()) {
783 ack_alarm_->Set(clock_->ApproximateNow().Add( 787 ack_alarm_->Set(clock_->ApproximateNow().Add(
784 congestion_manager_.DefaultRetransmissionTime())); 788 congestion_manager_.DelayedAckTime()));
785 } 789 }
786 } 790 }
787 send_ack_in_response_to_packet_ = !send_ack_in_response_to_packet_; 791 send_ack_in_response_to_packet_ = !send_ack_in_response_to_packet_;
788 } 792 }
789 793
790 if (!last_ack_frames_.empty()) { 794 if (!last_ack_frames_.empty()) {
791 // Now the we have received an ack, we might be able to send packets which 795 // Now the we have received an ack, we might be able to send packets which
792 // are queued locally, or drain streams which are blocked. 796 // are queued locally, or drain streams which are blocked.
793 QuicTime::Delta delay = congestion_manager_.TimeUntilSend( 797 QuicTime::Delta delay = congestion_manager_.TimeUntilSend(
794 time_of_last_received_packet_, NOT_RETRANSMISSION, 798 time_of_last_received_packet_, NOT_RETRANSMISSION,
(...skipping 15 matching lines...) Expand all
810 supported_versions.push_back(kSupportedQuicVersions[i]); 814 supported_versions.push_back(kSupportedQuicVersions[i]);
811 } 815 }
812 QuicEncryptedPacket* encrypted = 816 QuicEncryptedPacket* encrypted =
813 packet_creator_.SerializeVersionNegotiationPacket(supported_versions); 817 packet_creator_.SerializeVersionNegotiationPacket(supported_versions);
814 // TODO(satyamshekhar): implement zero server state negotiation. 818 // TODO(satyamshekhar): implement zero server state negotiation.
815 int error; 819 int error;
816 helper_->WritePacketToWire(*encrypted, &error); 820 helper_->WritePacketToWire(*encrypted, &error);
817 delete encrypted; 821 delete encrypted;
818 } 822 }
819 823
820 QuicConsumedData QuicConnection::SendStreamData(QuicStreamId id, 824 QuicConsumedData QuicConnection::SendvStreamData(QuicStreamId id,
821 StringPiece data, 825 const struct iovec* iov,
822 QuicStreamOffset offset, 826 int count,
823 bool fin) { 827 QuicStreamOffset offset,
824 // To make reasoning about crypto frames easier, we don't combine them with 828 bool fin) {
825 // any other frames in a single packet. 829 // TODO(ianswett): Further improve sending by passing the iovec down
826 const bool crypto_frame_while_batch_mode = 830 // instead of batching into multiple stream frames in a single packet.
827 id == kCryptoStreamId && packet_generator_.InBatchMode(); 831 const bool already_in_batch_mode = packet_generator_.InBatchMode();
832 packet_generator_.StartBatchOperations();
828 833
829 if (crypto_frame_while_batch_mode) { 834 size_t bytes_written = 0;
830 // Flush pending frames to make room for a crypto frame. 835 bool fin_consumed = false;
836 for (int i = 0; i < count; ++i) {
837 bool send_fin = fin && (i == count - 1);
838 if (!send_fin && iov[i].iov_len == 0) {
839 LOG(DFATAL) << "Attempt to send empty stream frame";
840 }
841 QuicConsumedData data_consumed = packet_generator_.ConsumeData(
842 id,
843 StringPiece(static_cast<char*>(iov[i].iov_base), iov[i].iov_len),
844 offset + bytes_written,
845 send_fin);
846 DCHECK_LE(data_consumed.bytes_consumed, numeric_limits<uint32>::max());
847 bytes_written += data_consumed.bytes_consumed;
848 fin_consumed = data_consumed.fin_consumed;
849 // If no bytes were consumed, bail now, because the stream can not write
850 // more data.
851 if (data_consumed.bytes_consumed < iov[i].iov_len) {
852 break;
853 }
854 }
855 // Handle the 0 byte write properly.
856 if (count == 0) {
857 DCHECK(fin);
858 QuicConsumedData data_consumed = packet_generator_.ConsumeData(
859 id, StringPiece(), offset, fin);
860 fin_consumed = data_consumed.fin_consumed;
861 }
862
863 // Leave the generator in the original batch state.
864 if (!already_in_batch_mode) {
831 packet_generator_.FinishBatchOperations(); 865 packet_generator_.FinishBatchOperations();
832 } 866 }
833 QuicConsumedData consumed_data = 867 DCHECK_EQ(already_in_batch_mode, packet_generator_.InBatchMode());
834 packet_generator_.ConsumeData(id, data, offset, fin); 868 return QuicConsumedData(bytes_written, fin_consumed);
835 if (crypto_frame_while_batch_mode) {
836 // Restore batch mode.
837 packet_generator_.StartBatchOperations();
838 }
839 return consumed_data;
840 } 869 }
841 870
842 QuicConsumedData QuicConnection::SendStreamDataAndNotifyWhenAcked( 871 QuicConsumedData QuicConnection::SendStreamDataAndNotifyWhenAcked(
843 QuicStreamId id, 872 QuicStreamId id,
844 StringPiece data, 873 StringPiece data,
845 QuicStreamOffset offset, 874 QuicStreamOffset offset,
846 bool fin, 875 bool fin,
847 QuicAckNotifier::DelegateInterface* delegate) { 876 QuicAckNotifier::DelegateInterface* delegate) {
877 if (!fin && data.empty()) {
878 LOG(DFATAL) << "Attempt to send empty stream frame";
879 }
848 // This notifier will be deleted in ProcessAckFrame once it has seen ACKs for 880 // This notifier will be deleted in ProcessAckFrame once it has seen ACKs for
849 // all the consumed data (or below if no data was consumed). 881 // all the consumed data (or below if no data was consumed).
850 QuicAckNotifier* notifier = new QuicAckNotifier(delegate); 882 QuicAckNotifier* notifier = new QuicAckNotifier(delegate);
851 QuicConsumedData consumed_data = 883 QuicConsumedData consumed_data =
852 packet_generator_.ConsumeData(id, data, offset, fin, notifier); 884 packet_generator_.ConsumeData(id, data, offset, fin, notifier);
853 885
854 if (consumed_data.bytes_consumed > 0) { 886 if (consumed_data.bytes_consumed > 0) {
855 // If some data was consumed, then the delegate should be registered for 887 // If some data was consumed, then the delegate should be registered for
856 // notification when the data is ACKed. 888 // notification when the data is ACKed.
857 ack_notifiers_.push_back(notifier); 889 ack_notifiers_.push_back(notifier);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 const IsHandshake maybe_handshake = 978 const IsHandshake maybe_handshake =
947 encryption_level_ == ENCRYPTION_FORWARD_SECURE ? NOT_HANDSHAKE 979 encryption_level_ == ENCRYPTION_FORWARD_SECURE ? NOT_HANDSHAKE
948 : IS_HANDSHAKE; 980 : IS_HANDSHAKE;
949 981
950 // Sending queued packets may have caused the socket to become write blocked, 982 // Sending queued packets may have caused the socket to become write blocked,
951 // or the congestion manager to prohibit sending. If we've sent everything 983 // or the congestion manager to prohibit sending. If we've sent everything
952 // we had queued and we're still not blocked, let the visitor know it can 984 // we had queued and we're still not blocked, let the visitor know it can
953 // write more. 985 // write more.
954 if (CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, 986 if (CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA,
955 maybe_handshake)) { 987 maybe_handshake)) {
956 const bool in_batch_mode = packet_generator_.InBatchMode(); 988 const bool already_in_batch_mode = packet_generator_.InBatchMode();
957 if (!in_batch_mode) { 989 if (!already_in_batch_mode) {
958 packet_generator_.StartBatchOperations(); 990 packet_generator_.StartBatchOperations();
959 } 991 }
960 bool all_bytes_written = visitor_->OnCanWrite(); 992 bool all_bytes_written = visitor_->OnCanWrite();
961 if (!in_batch_mode) { 993 if (!already_in_batch_mode) {
962 packet_generator_.FinishBatchOperations(); 994 packet_generator_.FinishBatchOperations();
963 } 995 }
964 996
965 // After the visitor writes, it may have caused the socket to become write 997 // After the visitor writes, it may have caused the socket to become write
966 // blocked or the congestion manager to prohibit sending, so check again. 998 // blocked or the congestion manager to prohibit sending, so check again.
967 // TODO(jar): we need to pass NOT_HANDSHAKE instead of maybe_handshake to 999 // TODO(jar): we need to pass NOT_HANDSHAKE instead of maybe_handshake to
968 // this CanWrite call to avoid getting into an infinite loop calling 1000 // this CanWrite call to avoid getting into an infinite loop calling
969 // DoWrite. 1001 // DoWrite.
970 if (!write_blocked_ && !all_bytes_written && 1002 if (!write_blocked_ && !all_bytes_written &&
971 CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, 1003 CanWrite(NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 << now.ToDebuggingValue(); 1330 << now.ToDebuggingValue();
1299 if (WritePacketToWire(sequence_number, level, *encrypted, &error) == -1) { 1331 if (WritePacketToWire(sequence_number, level, *encrypted, &error) == -1) {
1300 if (helper_->IsWriteBlocked(error)) { 1332 if (helper_->IsWriteBlocked(error)) {
1301 // TODO(satyashekhar): It might be more efficient (fewer system calls), if 1333 // TODO(satyashekhar): It might be more efficient (fewer system calls), if
1302 // all connections share this variable i.e this becomes a part of 1334 // all connections share this variable i.e this becomes a part of
1303 // PacketWriterInterface. 1335 // PacketWriterInterface.
1304 write_blocked_ = true; 1336 write_blocked_ = true;
1305 // If the socket buffers the the data, then the packet should not 1337 // If the socket buffers the the data, then the packet should not
1306 // be queued and sent again, which would result in an unnecessary 1338 // be queued and sent again, which would result in an unnecessary
1307 // duplicate packet being sent. 1339 // duplicate packet being sent.
1308 return helper_->IsWriteBlockedDataBuffered(); 1340 if (helper_->IsWriteBlockedDataBuffered()) {
1341 delete packet;
1342 return true;
1343 }
1344 return false;
1309 } 1345 }
1310 // We can't send an error as the socket is presumably borked. 1346 // We can't send an error as the socket is presumably borked.
1311 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); 1347 CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
1312 return false; 1348 return false;
1313 } 1349 }
1314 1350
1315 // Set the retransmit alarm only when we have sent the packet to the client 1351 // Set the retransmit alarm only when we have sent the packet to the client
1316 // and not when it goes to the pending queue, otherwise we will end up adding 1352 // and not when it goes to the pending queue, otherwise we will end up adding
1317 // an entry to retransmission_timeout_ every time we attempt a write. 1353 // an entry to retransmission_timeout_ every time we attempt a write.
1318 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { 1354 if (retransmittable == HAS_RETRANSMITTABLE_DATA) {
1319 SetupRetransmission(sequence_number, level); 1355 SetupRetransmission(sequence_number, level);
1320 } else if (packet->is_fec_packet()) { 1356 } else if (packet->is_fec_packet()) {
1321 SetupAbandonFecTimer(sequence_number); 1357 SetupAbandonFecTimer(sequence_number);
1322 } 1358 }
1323 1359
1324 // TODO(ianswett): Change the sequence number length and other packet creator 1360 // TODO(ianswett): Change the sequence number length and other packet creator
1325 // options by a more explicit API than setting a struct value directly. 1361 // options by a more explicit API than setting a struct value directly.
1326 packet_creator_.options()->send_sequence_number_length = 1362 packet_creator_.UpdateSequenceNumberLength(
1327 CalculateSequenceNumberLength(sequence_number); 1363 received_packet_manager_.least_packet_awaited_by_peer(),
1364 congestion_manager_.BandwidthEstimate().ToBytesPerPeriod(
1365 congestion_manager_.SmoothedRtt()));
1328 1366
1329 congestion_manager_.SentPacket(sequence_number, now, packet->length(), 1367 congestion_manager_.SentPacket(sequence_number, now, packet->length(),
1330 retransmission); 1368 retransmission, retransmittable);
1331 1369
1332 stats_.bytes_sent += encrypted->length(); 1370 stats_.bytes_sent += encrypted->length();
1333 ++stats_.packets_sent; 1371 ++stats_.packets_sent;
1334 1372
1335 if (retransmission == IS_RETRANSMISSION) { 1373 if (retransmission == IS_RETRANSMISSION) {
1336 stats_.bytes_retransmitted += encrypted->length(); 1374 stats_.bytes_retransmitted += encrypted->length();
1337 ++stats_.packets_retransmitted; 1375 ++stats_.packets_retransmitted;
1338 } 1376 }
1339 1377
1340 delete packet; 1378 delete packet;
1341 return true; 1379 return true;
1342 } 1380 }
1343 1381
1344 int QuicConnection::WritePacketToWire(QuicPacketSequenceNumber sequence_number, 1382 int QuicConnection::WritePacketToWire(QuicPacketSequenceNumber sequence_number,
1345 EncryptionLevel level, 1383 EncryptionLevel level,
1346 const QuicEncryptedPacket& packet, 1384 const QuicEncryptedPacket& packet,
1347 int* error) { 1385 int* error) {
1348 int bytes_written = helper_->WritePacketToWire(packet, error); 1386 int bytes_written = helper_->WritePacketToWire(packet, error);
1349 if (debug_visitor_) { 1387 if (debug_visitor_) {
1350 // WritePacketToWire returned -1, then |error| will be populated with 1388 // WritePacketToWire returned -1, then |error| will be populated with
1351 // an error code, which we want to pass along to the visitor. 1389 // an error code, which we want to pass along to the visitor.
1352 debug_visitor_->OnPacketSent(sequence_number, level, packet, 1390 debug_visitor_->OnPacketSent(sequence_number, level, packet,
1353 bytes_written == -1 ? *error : bytes_written); 1391 bytes_written == -1 ? *error : bytes_written);
1354 } 1392 }
1355 return bytes_written; 1393 return bytes_written;
1356 } 1394 }
1357 1395
1358 QuicSequenceNumberLength QuicConnection::CalculateSequenceNumberLength(
1359 QuicPacketSequenceNumber sequence_number) {
1360 DCHECK_LE(received_packet_manager_.least_packet_awaited_by_peer(),
1361 sequence_number);
1362 // Since the packet creator will not change sequence number length mid FEC
1363 // group, include the size of an FEC group to be safe.
1364 const QuicPacketSequenceNumber current_delta =
1365 packet_creator_.options()->max_packets_per_fec_group + sequence_number
1366 - received_packet_manager_.least_packet_awaited_by_peer();
1367 const uint64 congestion_window =
1368 congestion_manager_.BandwidthEstimate().ToBytesPerPeriod(
1369 congestion_manager_.SmoothedRtt()) /
1370 packet_creator_.options()->max_packet_length;
1371 const uint64 delta = max(current_delta, congestion_window);
1372
1373 if (delta < 1 << ((PACKET_1BYTE_SEQUENCE_NUMBER * 8) - 2)) {
1374 return PACKET_1BYTE_SEQUENCE_NUMBER;
1375 } else if (delta < 1 << ((PACKET_2BYTE_SEQUENCE_NUMBER * 8) - 2)) {
1376 return PACKET_2BYTE_SEQUENCE_NUMBER;
1377 } else if (delta < 1 << ((PACKET_4BYTE_SEQUENCE_NUMBER * 8) - 2)) {
1378 return PACKET_4BYTE_SEQUENCE_NUMBER;
1379 }
1380 return PACKET_6BYTE_SEQUENCE_NUMBER;
1381 }
1382
1383 bool QuicConnection::OnSerializedPacket( 1396 bool QuicConnection::OnSerializedPacket(
1384 const SerializedPacket& serialized_packet) { 1397 const SerializedPacket& serialized_packet) {
1385 if (serialized_packet.retransmittable_frames != NULL) { 1398 if (serialized_packet.retransmittable_frames != NULL) {
1386 DCHECK(unacked_packets_.empty() || 1399 DCHECK(unacked_packets_.empty() ||
1387 unacked_packets_.rbegin()->first < 1400 unacked_packets_.rbegin()->first <
1388 serialized_packet.sequence_number); 1401 serialized_packet.sequence_number);
1389 // Retransmitted frames will be sent with the same encryption level as the 1402 // Retransmitted frames will be sent with the same encryption level as the
1390 // original. 1403 // original.
1391 serialized_packet.retransmittable_frames->set_encryption_level( 1404 serialized_packet.retransmittable_frames->set_encryption_level(
1392 encryption_level_); 1405 encryption_level_);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 QuicFecGroup* fec_group = it->second; 1722 QuicFecGroup* fec_group = it->second;
1710 DCHECK(!fec_group->CanRevive()); 1723 DCHECK(!fec_group->CanRevive());
1711 FecGroupMap::iterator next = it; 1724 FecGroupMap::iterator next = it;
1712 ++next; 1725 ++next;
1713 group_map_.erase(it); 1726 group_map_.erase(it);
1714 delete fec_group; 1727 delete fec_group;
1715 it = next; 1728 it = next;
1716 } 1729 }
1717 } 1730 }
1718 1731
1732 void QuicConnection::Flush() {
1733 if (!packet_generator_.InBatchMode()) {
1734 return;
1735 }
1736 packet_generator_.FinishBatchOperations();
1737 packet_generator_.StartBatchOperations();
1738 }
1739
1719 bool QuicConnection::HasQueuedData() const { 1740 bool QuicConnection::HasQueuedData() const {
1720 return !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); 1741 return !queued_packets_.empty() || packet_generator_.HasQueuedFrames();
1721 } 1742 }
1722 1743
1723 void QuicConnection::SetIdleNetworkTimeout(QuicTime::Delta timeout) { 1744 void QuicConnection::SetIdleNetworkTimeout(QuicTime::Delta timeout) {
1724 if (timeout < idle_network_timeout_) { 1745 if (timeout < idle_network_timeout_) {
1725 idle_network_timeout_ = timeout; 1746 idle_network_timeout_ = timeout;
1726 CheckForTimeout(); 1747 CheckForTimeout();
1727 } else { 1748 } else {
1728 idle_network_timeout_ = timeout; 1749 idle_network_timeout_ = timeout;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 timeout = connection_timeout; 1801 timeout = connection_timeout;
1781 } 1802 }
1782 } 1803 }
1783 1804
1784 timeout_alarm_->Cancel(); 1805 timeout_alarm_->Cancel();
1785 timeout_alarm_->Set(clock_->ApproximateNow().Add(timeout)); 1806 timeout_alarm_->Set(clock_->ApproximateNow().Add(timeout));
1786 return false; 1807 return false;
1787 } 1808 }
1788 1809
1789 } // namespace net 1810 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698