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

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

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { 461 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
462 return true; 462 return true;
463 } 463 }
464 464
465 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { 465 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) {
466 last_decrypted_packet_level_ = level; 466 last_decrypted_packet_level_ = level;
467 last_packet_decrypted_ = true; 467 last_packet_decrypted_ = true;
468 // If this packet was foward-secure encrypted and the forward-secure encrypter 468 // If this packet was foward-secure encrypted and the forward-secure encrypter
469 // is not being used, start using it. 469 // is not being used, start using it.
470 if (FLAGS_enable_quic_delay_forward_security && 470 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
471 encryption_level_ != ENCRYPTION_FORWARD_SECURE && 471 has_forward_secure_encrypter_ && level == ENCRYPTION_FORWARD_SECURE) {
472 has_forward_secure_encrypter_ &&
473 level == ENCRYPTION_FORWARD_SECURE) {
474 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 472 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
475 } 473 }
476 } 474 }
477 475
478 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { 476 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
479 if (debug_visitor_.get() != nullptr) { 477 if (debug_visitor_.get() != nullptr) {
480 debug_visitor_->OnPacketHeader(header); 478 debug_visitor_->OnPacketHeader(header);
481 } 479 }
482 480
483 if (!ProcessValidatedPacket()) { 481 if (!ProcessValidatedPacket()) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 last_stop_waiting_frames_.clear(); 933 last_stop_waiting_frames_.clear();
936 last_rst_frames_.clear(); 934 last_rst_frames_.clear();
937 last_goaway_frames_.clear(); 935 last_goaway_frames_.clear();
938 last_window_update_frames_.clear(); 936 last_window_update_frames_.clear();
939 last_blocked_frames_.clear(); 937 last_blocked_frames_.clear();
940 last_ping_frames_.clear(); 938 last_ping_frames_.clear();
941 last_close_frames_.clear(); 939 last_close_frames_.clear();
942 } 940 }
943 941
944 void QuicConnection::MaybeCloseIfTooManyOutstandingPackets() { 942 void QuicConnection::MaybeCloseIfTooManyOutstandingPackets() {
945 if (!FLAGS_quic_too_many_outstanding_packets) {
946 return;
947 }
948 // This occurs if we don't discard old packets we've sent fast enough. 943 // This occurs if we don't discard old packets we've sent fast enough.
949 // It's possible largest observed is less than least unacked. 944 // It's possible largest observed is less than least unacked.
950 if (sent_packet_manager_.largest_observed() > 945 if (sent_packet_manager_.largest_observed() >
951 (sent_packet_manager_.GetLeastUnacked() + kMaxTrackedPackets)) { 946 (sent_packet_manager_.GetLeastUnacked() + kMaxTrackedPackets)) {
952 SendConnectionCloseWithDetails( 947 SendConnectionCloseWithDetails(
953 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, 948 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS,
954 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets)); 949 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets));
955 } 950 }
956 // This occurs if there are received packet gaps and the peer does not raise 951 // This occurs if there are received packet gaps and the peer does not raise
957 // the least unacked fast enough. 952 // the least unacked fast enough.
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 << " (" << ErrorToString(error_code) << ")"; 1572 << " (" << ErrorToString(error_code) << ")";
1578 // We can't send an error as the socket is presumably borked. 1573 // We can't send an error as the socket is presumably borked.
1579 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); 1574 CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
1580 } 1575 }
1581 1576
1582 void QuicConnection::OnSerializedPacket( 1577 void QuicConnection::OnSerializedPacket(
1583 const SerializedPacket& serialized_packet) { 1578 const SerializedPacket& serialized_packet) {
1584 // If a forward-secure encrypter is available but is not being used and this 1579 // If a forward-secure encrypter is available but is not being used and this
1585 // packet's sequence number is after the first packet which requires 1580 // packet's sequence number is after the first packet which requires
1586 // forward security, start using the forward-secure encrypter. 1581 // forward security, start using the forward-secure encrypter.
1587 if (FLAGS_enable_quic_delay_forward_security && 1582 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
1588 encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
1589 has_forward_secure_encrypter_ && 1583 has_forward_secure_encrypter_ &&
1590 serialized_packet.sequence_number >= 1584 serialized_packet.sequence_number >=
1591 first_required_forward_secure_packet_) { 1585 first_required_forward_secure_packet_) {
1592 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 1586 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1593 } 1587 }
1594 if (serialized_packet.retransmittable_frames) { 1588 if (serialized_packet.retransmittable_frames) {
1595 serialized_packet.retransmittable_frames-> 1589 serialized_packet.retransmittable_frames->
1596 set_encryption_level(encryption_level_); 1590 set_encryption_level(encryption_level_);
1597 } 1591 }
1598 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_)); 1592 SendOrQueuePacket(QueuedPacket(serialized_packet, encryption_level_));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 QuicTime rto_timeout = sent_packet_manager_.GetRetransmissionTime(); 1683 QuicTime rto_timeout = sent_packet_manager_.GetRetransmissionTime();
1690 if (rto_timeout.IsInitialized()) { 1684 if (rto_timeout.IsInitialized()) {
1691 retransmission_alarm_->Set(rto_timeout); 1685 retransmission_alarm_->Set(rto_timeout);
1692 } 1686 }
1693 } 1687 }
1694 } 1688 }
1695 1689
1696 void QuicConnection::SetEncrypter(EncryptionLevel level, 1690 void QuicConnection::SetEncrypter(EncryptionLevel level,
1697 QuicEncrypter* encrypter) { 1691 QuicEncrypter* encrypter) {
1698 framer_.SetEncrypter(level, encrypter); 1692 framer_.SetEncrypter(level, encrypter);
1699 if (FLAGS_enable_quic_delay_forward_security && 1693 if (level == ENCRYPTION_FORWARD_SECURE) {
1700 level == ENCRYPTION_FORWARD_SECURE) {
1701 has_forward_secure_encrypter_ = true; 1694 has_forward_secure_encrypter_ = true;
1702 first_required_forward_secure_packet_ = 1695 first_required_forward_secure_packet_ =
1703 sequence_number_of_last_sent_packet_ + 1696 sequence_number_of_last_sent_packet_ +
1704 // 3 times the current congestion window (in slow start) should cover 1697 // 3 times the current congestion window (in slow start) should cover
1705 // about two full round trips worth of packets, which should be 1698 // about two full round trips worth of packets, which should be
1706 // sufficient. 1699 // sufficient.
1707 3 * sent_packet_manager_.EstimateMaxPacketsInFlight( 1700 3 * sent_packet_manager_.EstimateMaxPacketsInFlight(
1708 max_packet_length()); 1701 max_packet_length());
1709 } 1702 }
1710 } 1703 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2092 }
2100 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2093 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2101 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2094 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2102 return true; 2095 return true;
2103 } 2096 }
2104 } 2097 }
2105 return false; 2098 return false;
2106 } 2099 }
2107 2100
2108 } // namespace net 2101 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698