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

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

Issue 2603723002: Add a new QUIC platform API for text utilities. (Closed)
Patch Set: Tests Created 3 years, 12 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
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/core/quic_connection.h" 5 #include "net/quic/core/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>
11 #include <iterator> 11 #include <iterator>
12 #include <limits> 12 #include <limits>
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/format_macros.h" 17 #include "base/format_macros.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h"
24 #include "net/base/address_family.h" 22 #include "net/base/address_family.h"
25 #include "net/base/ip_address.h" 23 #include "net/base/ip_address.h"
26 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
27 #include "net/quic/core/crypto/crypto_protocol.h" 25 #include "net/quic/core/crypto/crypto_protocol.h"
28 #include "net/quic/core/crypto/quic_decrypter.h" 26 #include "net/quic/core/crypto/quic_decrypter.h"
29 #include "net/quic/core/crypto/quic_encrypter.h" 27 #include "net/quic/core/crypto/quic_encrypter.h"
30 #include "net/quic/core/proto/cached_network_parameters.pb.h" 28 #include "net/quic/core/proto/cached_network_parameters.pb.h"
31 #include "net/quic/core/quic_bandwidth.h" 29 #include "net/quic/core/quic_bandwidth.h"
32 #include "net/quic/core/quic_bug_tracker.h" 30 #include "net/quic/core/quic_bug_tracker.h"
33 #include "net/quic/core/quic_config.h" 31 #include "net/quic/core/quic_config.h"
34 #include "net/quic/core/quic_flags.h" 32 #include "net/quic/core/quic_flags.h"
35 #include "net/quic/core/quic_packet_generator.h" 33 #include "net/quic/core/quic_packet_generator.h"
36 #include "net/quic/core/quic_pending_retransmission.h" 34 #include "net/quic/core/quic_pending_retransmission.h"
37 #include "net/quic/core/quic_sent_packet_manager.h" 35 #include "net/quic/core/quic_sent_packet_manager.h"
38 #include "net/quic/core/quic_utils.h" 36 #include "net/quic/core/quic_utils.h"
39 #include "net/quic/platform/api/quic_str_cat.h" 37 #include "net/quic/platform/api/quic_str_cat.h"
38 #include "net/quic/platform/api/quic_text_utils.h"
40 39
41 using base::StringPiece; 40 using base::StringPiece;
42 using base::StringPrintf;
43 using std::string; 41 using std::string;
44 42
45 namespace net { 43 namespace net {
46 44
47 class QuicDecrypter; 45 class QuicDecrypter;
48 class QuicEncrypter; 46 class QuicEncrypter;
49 47
50 namespace { 48 namespace {
51 49
52 // The largest gap in packets we'll accept without closing the connection. 50 // The largest gap in packets we'll accept without closing the connection.
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 if (should_last_packet_instigate_acks_ && !ack_queued_) { 1004 if (should_last_packet_instigate_acks_ && !ack_queued_) {
1007 ++num_retransmittable_packets_received_since_last_ack_sent_; 1005 ++num_retransmittable_packets_received_since_last_ack_sent_;
1008 if (ack_mode_ != TCP_ACKING && 1006 if (ack_mode_ != TCP_ACKING &&
1009 last_header_.packet_number > kMinReceivedBeforeAckDecimation) { 1007 last_header_.packet_number > kMinReceivedBeforeAckDecimation) {
1010 // Ack up to 10 packets at once. 1008 // Ack up to 10 packets at once.
1011 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1009 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
1012 kMaxRetransmittablePacketsBeforeAck) { 1010 kMaxRetransmittablePacketsBeforeAck) {
1013 ack_queued_ = true; 1011 ack_queued_ = true;
1014 } else if (!ack_alarm_->IsSet()) { 1012 } else if (!ack_alarm_->IsSet()) {
1015 // Wait the minimum of a quarter min_rtt and the delayed ack time. 1013 // Wait the minimum of a quarter min_rtt and the delayed ack time.
1016 QuicTime::Delta ack_delay = std::min( 1014 QuicTime::Delta ack_delay =
1017 DelayedAckTime(), sent_packet_manager_->GetRttStats()->min_rtt() * 1015 std::min(DelayedAckTime(),
1018 ack_decimation_delay_); 1016 sent_packet_manager_->GetRttStats()->min_rtt() *
1017 ack_decimation_delay_);
1019 ack_alarm_->Set(clock_->ApproximateNow() + ack_delay); 1018 ack_alarm_->Set(clock_->ApproximateNow() + ack_delay);
1020 } 1019 }
1021 } else { 1020 } else {
1022 // Ack with a timer or every 2 packets by default. 1021 // Ack with a timer or every 2 packets by default.
1023 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1022 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
1024 kDefaultRetransmittablePacketsBeforeAck) { 1023 kDefaultRetransmittablePacketsBeforeAck) {
1025 ack_queued_ = true; 1024 ack_queued_ = true;
1026 } else if (!ack_alarm_->IsSet()) { 1025 } else if (!ack_alarm_->IsSet()) {
1027 ack_alarm_->Set(clock_->ApproximateNow() + DelayedAckTime()); 1026 ack_alarm_->Set(clock_->ApproximateNow() + DelayedAckTime());
1028 } 1027 }
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 DCHECK_LE(encrypted_length, kMaxPacketSize); 1569 DCHECK_LE(encrypted_length, kMaxPacketSize);
1571 DCHECK_LE(encrypted_length, packet_generator_.GetCurrentMaxPacketLength()); 1570 DCHECK_LE(encrypted_length, packet_generator_.GetCurrentMaxPacketLength());
1572 DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " 1571 DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : "
1573 << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA 1572 << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA
1574 ? "data bearing " 1573 ? "data bearing "
1575 : " ack only ") 1574 : " ack only ")
1576 << ", encryption level: " 1575 << ", encryption level: "
1577 << QuicUtils::EncryptionLevelToString(packet->encryption_level) 1576 << QuicUtils::EncryptionLevelToString(packet->encryption_level)
1578 << ", encrypted length:" << encrypted_length; 1577 << ", encrypted length:" << encrypted_length;
1579 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl 1578 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl
1580 << QuicUtils::HexDump( 1579 << QuicTextUtils::HexDump(
1581 StringPiece(packet->encrypted_buffer, encrypted_length)); 1580 StringPiece(packet->encrypted_buffer, encrypted_length));
1582 1581
1583 // Measure the RTT from before the write begins to avoid underestimating the 1582 // Measure the RTT from before the write begins to avoid underestimating the
1584 // min_rtt_, especially in cases where the thread blocks or gets swapped out 1583 // min_rtt_, especially in cases where the thread blocks or gets swapped out
1585 // during the WritePacket below. 1584 // during the WritePacket below.
1586 QuicTime packet_send_time = clock_->Now(); 1585 QuicTime packet_send_time = clock_->Now();
1587 WriteResult result = writer_->WritePacket( 1586 WriteResult result = writer_->WritePacket(
1588 packet->encrypted_buffer, encrypted_length, self_address().host(), 1587 packet->encrypted_buffer, encrypted_length, self_address().host(),
1589 peer_address(), per_packet_options_); 1588 peer_address(), per_packet_options_);
1590 if (result.error_code == ERR_IO_PENDING) { 1589 if (result.error_code == ERR_IO_PENDING) {
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 2457
2459 void QuicConnection::CheckIfApplicationLimited() { 2458 void QuicConnection::CheckIfApplicationLimited() {
2460 if (queued_packets_.empty() && 2459 if (queued_packets_.empty() &&
2461 !sent_packet_manager_->HasPendingRetransmissions() && 2460 !sent_packet_manager_->HasPendingRetransmissions() &&
2462 !visitor_->WillingAndAbleToWrite()) { 2461 !visitor_->WillingAndAbleToWrite()) {
2463 sent_packet_manager_->OnApplicationLimited(); 2462 sent_packet_manager_->OnApplicationLimited();
2464 } 2463 }
2465 } 2464 }
2466 2465
2467 } // namespace net 2466 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698