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

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

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 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/core/quic_connection.h ('k') | net/quic/core/quic_connection_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/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/macros.h" 18 #include "base/macros.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "net/quic/core/crypto/crypto_protocol.h" 21 #include "net/quic/core/crypto/crypto_protocol.h"
22 #include "net/quic/core/crypto/quic_decrypter.h" 22 #include "net/quic/core/crypto/quic_decrypter.h"
23 #include "net/quic/core/crypto/quic_encrypter.h" 23 #include "net/quic/core/crypto/quic_encrypter.h"
24 #include "net/quic/core/proto/cached_network_parameters.pb.h" 24 #include "net/quic/core/proto/cached_network_parameters.pb.h"
25 #include "net/quic/core/quic_bandwidth.h" 25 #include "net/quic/core/quic_bandwidth.h"
26 #include "net/quic/core/quic_config.h" 26 #include "net/quic/core/quic_config.h"
27 #include "net/quic/core/quic_flags.h"
28 #include "net/quic/core/quic_packet_generator.h" 27 #include "net/quic/core/quic_packet_generator.h"
29 #include "net/quic/core/quic_pending_retransmission.h" 28 #include "net/quic/core/quic_pending_retransmission.h"
30 #include "net/quic/core/quic_utils.h" 29 #include "net/quic/core/quic_utils.h"
31 #include "net/quic/platform/api/quic_bug_tracker.h" 30 #include "net/quic/platform/api/quic_bug_tracker.h"
32 #include "net/quic/platform/api/quic_flag_utils.h" 31 #include "net/quic/platform/api/quic_flag_utils.h"
32 #include "net/quic/platform/api/quic_flags.h"
33 #include "net/quic/platform/api/quic_logging.h" 33 #include "net/quic/platform/api/quic_logging.h"
34 #include "net/quic/platform/api/quic_map_util.h" 34 #include "net/quic/platform/api/quic_map_util.h"
35 #include "net/quic/platform/api/quic_str_cat.h" 35 #include "net/quic/platform/api/quic_str_cat.h"
36 #include "net/quic/platform/api/quic_text_utils.h" 36 #include "net/quic/platform/api/quic_text_utils.h"
37 37
38 using std::string; 38 using std::string;
39 39
40 namespace net { 40 namespace net {
41 41
42 class QuicDecrypter; 42 class QuicDecrypter;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ping_alarm_( 233 ping_alarm_(
234 alarm_factory_->CreateAlarm(arena_.New<PingAlarmDelegate>(this), 234 alarm_factory_->CreateAlarm(arena_.New<PingAlarmDelegate>(this),
235 &arena_)), 235 &arena_)),
236 mtu_discovery_alarm_(alarm_factory_->CreateAlarm( 236 mtu_discovery_alarm_(alarm_factory_->CreateAlarm(
237 arena_.New<MtuDiscoveryAlarmDelegate>(this), 237 arena_.New<MtuDiscoveryAlarmDelegate>(this),
238 &arena_)), 238 &arena_)),
239 visitor_(nullptr), 239 visitor_(nullptr),
240 debug_visitor_(nullptr), 240 debug_visitor_(nullptr),
241 packet_generator_(connection_id_, 241 packet_generator_(connection_id_,
242 &framer_, 242 &framer_,
243 random_generator_,
243 helper->GetBufferAllocator(), 244 helper->GetBufferAllocator(),
244 this), 245 this),
245 idle_network_timeout_(QuicTime::Delta::Infinite()), 246 idle_network_timeout_(QuicTime::Delta::Infinite()),
246 handshake_timeout_(QuicTime::Delta::Infinite()), 247 handshake_timeout_(QuicTime::Delta::Infinite()),
247 time_of_last_received_packet_(clock_->ApproximateNow()), 248 time_of_last_received_packet_(clock_->ApproximateNow()),
248 time_of_last_sent_new_packet_(clock_->ApproximateNow()), 249 time_of_last_sent_new_packet_(clock_->ApproximateNow()),
249 last_send_for_timeout_(clock_->ApproximateNow()), 250 last_send_for_timeout_(clock_->ApproximateNow()),
250 sent_packet_manager_(perspective, clock_, &stats_, kCubicBytes, kNack), 251 sent_packet_manager_(perspective, clock_, &stats_, kCubicBytes, kNack),
251 version_negotiation_state_(START_NEGOTIATION), 252 version_negotiation_state_(START_NEGOTIATION),
252 perspective_(perspective), 253 perspective_(perspective),
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 return; 1051 return;
1051 } 1052 }
1052 1053
1053 pending_version_negotiation_packet_ = false; 1054 pending_version_negotiation_packet_ = false;
1054 } 1055 }
1055 1056
1056 QuicConsumedData QuicConnection::SendStreamData( 1057 QuicConsumedData QuicConnection::SendStreamData(
1057 QuicStreamId id, 1058 QuicStreamId id,
1058 QuicIOVector iov, 1059 QuicIOVector iov,
1059 QuicStreamOffset offset, 1060 QuicStreamOffset offset,
1060 bool fin, 1061 StreamSendingState state,
1061 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { 1062 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) {
1062 if (!fin && iov.total_length == 0) { 1063 if (state == NO_FIN && iov.total_length == 0) {
1063 QUIC_BUG << "Attempt to send empty stream frame"; 1064 QUIC_BUG << "Attempt to send empty stream frame";
1064 return QuicConsumedData(0, false); 1065 return QuicConsumedData(0, false);
1065 } 1066 }
1066 1067
1067 // Opportunistically bundle an ack with every outgoing packet. 1068 // Opportunistically bundle an ack with every outgoing packet.
1068 // Particularly, we want to bundle with handshake packets since we don't know 1069 // Particularly, we want to bundle with handshake packets since we don't know
1069 // which decrypter will be used on an ack packet following a handshake 1070 // which decrypter will be used on an ack packet following a handshake
1070 // packet (a handshake packet from client to server could result in a REJ or a 1071 // packet (a handshake packet from client to server could result in a REJ or a
1071 // SHLO from the server, leading to two different decrypters at the server.) 1072 // SHLO from the server, leading to two different decrypters at the server.)
1072 ScopedRetransmissionScheduler alarm_delayer(this); 1073 ScopedRetransmissionScheduler alarm_delayer(this);
1073 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); 1074 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING);
1074 // The optimized path may be used for data only packets which fit into a 1075 // The optimized path may be used for data only packets which fit into a
1075 // standard buffer and don't need padding. 1076 // standard buffer and don't need padding.
1076 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() && 1077 if (id != kCryptoStreamId && !packet_generator_.HasQueuedFrames() &&
1077 iov.total_length > kMaxPacketSize) { 1078 iov.total_length > kMaxPacketSize && state != FIN_AND_PADDING) {
1078 // Use the fast path to send full data packets. 1079 // Use the fast path to send full data packets.
1079 return packet_generator_.ConsumeDataFastPath(id, iov, offset, fin, 1080 return packet_generator_.ConsumeDataFastPath(
1080 std::move(ack_listener)); 1081 id, iov, offset, state != NO_FIN, std::move(ack_listener));
1081 } 1082 }
1082 return packet_generator_.ConsumeData(id, iov, offset, fin, 1083 return packet_generator_.ConsumeData(id, iov, offset, state,
1083 std::move(ack_listener)); 1084 std::move(ack_listener));
1084 } 1085 }
1085 1086
1086 void QuicConnection::SendRstStream(QuicStreamId id, 1087 void QuicConnection::SendRstStream(QuicStreamId id,
1087 QuicRstStreamErrorCode error, 1088 QuicRstStreamErrorCode error,
1088 QuicStreamOffset bytes_written) { 1089 QuicStreamOffset bytes_written) {
1089 // Opportunistically bundle an ack with this outgoing packet. 1090 // Opportunistically bundle an ack with this outgoing packet.
1090 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); 1091 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING);
1091 packet_generator_.AddControlFrame( 1092 packet_generator_.AddControlFrame(
1092 QuicFrame(new QuicRstStreamFrame(id, error, bytes_written))); 1093 QuicFrame(new QuicRstStreamFrame(id, error, bytes_written)));
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 2388
2388 void QuicConnection::CheckIfApplicationLimited() { 2389 void QuicConnection::CheckIfApplicationLimited() {
2389 if (queued_packets_.empty() && 2390 if (queued_packets_.empty() &&
2390 !sent_packet_manager_.HasPendingRetransmissions() && 2391 !sent_packet_manager_.HasPendingRetransmissions() &&
2391 !visitor_->WillingAndAbleToWrite()) { 2392 !visitor_->WillingAndAbleToWrite()) {
2392 sent_packet_manager_.OnApplicationLimited(); 2393 sent_packet_manager_.OnApplicationLimited();
2393 } 2394 }
2394 } 2395 }
2395 2396
2396 } // namespace net 2397 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection.h ('k') | net/quic/core/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698