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

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

Issue 1525303003: Remove QuicPacketGenerator::OnSerializedPacket with functionality in QuicPacketCreator. No functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@110008813
Patch Set: get newly added files from upstream Created 5 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
« no previous file with comments | « net/quic/quic_packet_generator.h ('k') | net/quic/quic_packet_generator_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_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/quic/quic_fec_group.h" 9 #include "net/quic/quic_fec_group.h"
10 #include "net/quic/quic_flags.h" 10 #include "net/quic/quic_flags.h"
11 #include "net/quic/quic_utils.h" 11 #include "net/quic/quic_utils.h"
12 12
13 using base::StringPiece; 13 using base::StringPiece;
14 14
15 namespace net { 15 namespace net {
16 16
17 class QuicAckNotifier; 17 class QuicAckNotifier;
18 18
19 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id, 19 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id,
20 QuicFramer* framer, 20 QuicFramer* framer,
21 QuicRandom* random_generator, 21 QuicRandom* random_generator,
22 DelegateInterface* delegate) 22 DelegateInterface* delegate)
23 : delegate_(delegate), 23 : delegate_(delegate),
24 packet_creator_(connection_id, framer, random_generator, this), 24 packet_creator_(connection_id, framer, random_generator, delegate),
25 batch_mode_(false), 25 batch_mode_(false),
26 should_send_ack_(false), 26 should_send_ack_(false),
27 should_send_stop_waiting_(false), 27 should_send_stop_waiting_(false),
28 max_packet_length_(kDefaultMaxPacketSize) {} 28 max_packet_length_(kDefaultMaxPacketSize) {}
29 29
30 QuicPacketGenerator::~QuicPacketGenerator() { 30 QuicPacketGenerator::~QuicPacketGenerator() {
31 for (QuicFrame& frame : queued_control_frames_) { 31 for (QuicFrame& frame : queued_control_frames_) {
32 switch (frame.type) { 32 switch (frame.type) {
33 case PADDING_FRAME: 33 case PADDING_FRAME:
34 case MTU_DISCOVERY_FRAME: 34 case MTU_DISCOVERY_FRAME:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 QuicFrame frame; 125 QuicFrame frame;
126 if (!packet_creator_.ConsumeData(id, iov, total_bytes_consumed, 126 if (!packet_creator_.ConsumeData(id, iov, total_bytes_consumed,
127 offset + total_bytes_consumed, fin, 127 offset + total_bytes_consumed, fin,
128 has_handshake, &frame, fec_protection)) { 128 has_handshake, &frame, fec_protection)) {
129 // Current packet is full and flushed. 129 // Current packet is full and flushed.
130 continue; 130 continue;
131 } 131 }
132 132
133 // A stream frame is created and added. 133 // A stream frame is created and added.
134 size_t bytes_consumed = frame.stream_frame->frame_length; 134 size_t bytes_consumed = frame.stream_frame->frame_length;
135
136 if (listener != nullptr) { 135 if (listener != nullptr) {
137 ack_listeners_.push_back(AckListenerWrapper(listener, bytes_consumed)); 136 packet_creator_.AddAckListener(listener, bytes_consumed);
138 } 137 }
139
140 total_bytes_consumed += bytes_consumed; 138 total_bytes_consumed += bytes_consumed;
141 fin_consumed = fin && total_bytes_consumed == iov.total_length; 139 fin_consumed = fin && total_bytes_consumed == iov.total_length;
142 DCHECK(total_bytes_consumed == iov.total_length || 140 DCHECK(total_bytes_consumed == iov.total_length ||
143 (bytes_consumed > 0 && packet_creator_.HasPendingFrames())); 141 (bytes_consumed > 0 && packet_creator_.HasPendingFrames()));
144 142
145 if (!InBatchMode()) { 143 if (!InBatchMode()) {
146 // TODO(rtenneti): remove MaybeSendFecPacketAndCloseGroup() from inside 144 // TODO(rtenneti): remove MaybeSendFecPacketAndCloseGroup() from inside
147 // SerializeAndSendPacket() and make it an explicit call here (and 145 // SerializeAndSendPacket() and make it an explicit call here (and
148 // elsewhere where we call SerializeAndSendPacket?). 146 // elsewhere where we call SerializeAndSendPacket?).
149 packet_creator_.Flush(); 147 packet_creator_.Flush();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 183
186 // The MTU discovery frame is allocated on the stack, since it is going to be 184 // The MTU discovery frame is allocated on the stack, since it is going to be
187 // serialized within this function. 185 // serialized within this function.
188 QuicMtuDiscoveryFrame mtu_discovery_frame; 186 QuicMtuDiscoveryFrame mtu_discovery_frame;
189 QuicFrame frame(mtu_discovery_frame); 187 QuicFrame frame(mtu_discovery_frame);
190 188
191 // Send the probe packet with the new length. 189 // Send the probe packet with the new length.
192 SetMaxPacketLength(target_mtu, /*force=*/true); 190 SetMaxPacketLength(target_mtu, /*force=*/true);
193 const bool success = packet_creator_.AddPaddedSavedFrame(frame); 191 const bool success = packet_creator_.AddPaddedSavedFrame(frame);
194 if (listener != nullptr) { 192 if (listener != nullptr) {
195 ack_listeners_.push_back(AckListenerWrapper(listener, 0)); 193 packet_creator_.AddAckListener(listener, 0);
196 } 194 }
197 packet_creator_.Flush(); 195 packet_creator_.Flush();
198 // The only reason AddFrame can fail is that the packet is too full to fit in 196 // The only reason AddFrame can fail is that the packet is too full to fit in
199 // a ping. This is not possible for any sane MTU. 197 // a ping. This is not possible for any sane MTU.
200 DCHECK(success); 198 DCHECK(success);
201 199
202 // Reset the packet length back. 200 // Reset the packet length back.
203 SetMaxPacketLength(current_mtu, /*force=*/true); 201 SetMaxPacketLength(current_mtu, /*force=*/true);
204 } 202 }
205 203
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 367
370 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { 368 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) {
371 packet_creator_.set_encryption_level(level); 369 packet_creator_.set_encryption_level(level);
372 } 370 }
373 371
374 void QuicPacketGenerator::SetEncrypter(EncryptionLevel level, 372 void QuicPacketGenerator::SetEncrypter(EncryptionLevel level,
375 QuicEncrypter* encrypter) { 373 QuicEncrypter* encrypter) {
376 packet_creator_.SetEncrypter(level, encrypter); 374 packet_creator_.SetEncrypter(level, encrypter);
377 } 375 }
378 376
379 void QuicPacketGenerator::OnSerializedPacket(
380 SerializedPacket* serialized_packet) {
381 if (serialized_packet->packet == nullptr) {
382 LOG(DFATAL) << "Failed to SerializePacket. fec_policy:" << fec_send_policy()
383 << " should_fec_protect_:"
384 << packet_creator_.should_fec_protect_next_packet();
385 delegate_->CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false);
386 return;
387 }
388
389 // There may be AckListeners interested in this packet.
390 serialized_packet->listeners.swap(ack_listeners_);
391 ack_listeners_.clear();
392
393 delegate_->OnSerializedPacket(*serialized_packet);
394 packet_creator_.MaybeSendFecPacketAndCloseGroup(/*force_send_fec=*/false,
395 /*is_fec_timeout=*/false);
396
397 // Maximum packet size may be only enacted while no packet is currently being
398 // constructed, so here we have a good opportunity to actually change it.
399 if (packet_creator_.CanSetMaxPacketLength()) {
400 packet_creator_.SetMaxPacketLength(max_packet_length_);
401 }
402 }
403
404 void QuicPacketGenerator::OnResetFecGroup() {
405 delegate_->OnResetFecGroup();
406 }
407
408 void QuicPacketGenerator::SetCurrentPath( 377 void QuicPacketGenerator::SetCurrentPath(
409 QuicPathId path_id, 378 QuicPathId path_id,
410 QuicPacketNumber least_packet_awaited_by_peer, 379 QuicPacketNumber least_packet_awaited_by_peer,
411 QuicPacketCount max_packets_in_flight) { 380 QuicPacketCount max_packets_in_flight) {
412 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, 381 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer,
413 max_packets_in_flight); 382 max_packets_in_flight);
414 } 383 }
415 384
416 void QuicPacketGenerator::set_rtt_multiplier_for_fec_timeout( 385 void QuicPacketGenerator::set_rtt_multiplier_for_fec_timeout(
417 float rtt_multiplier_for_fec_timeout) { 386 float rtt_multiplier_for_fec_timeout) {
418 packet_creator_.set_rtt_multiplier_for_fec_timeout( 387 packet_creator_.set_rtt_multiplier_for_fec_timeout(
419 rtt_multiplier_for_fec_timeout); 388 rtt_multiplier_for_fec_timeout);
420 } 389 }
421 390
422 FecSendPolicy QuicPacketGenerator::fec_send_policy() { 391 FecSendPolicy QuicPacketGenerator::fec_send_policy() {
423 return packet_creator_.fec_send_policy(); 392 return packet_creator_.fec_send_policy();
424 } 393 }
425 394
426 void QuicPacketGenerator::set_fec_send_policy(FecSendPolicy fec_send_policy) { 395 void QuicPacketGenerator::set_fec_send_policy(FecSendPolicy fec_send_policy) {
427 packet_creator_.set_fec_send_policy(fec_send_policy); 396 packet_creator_.set_fec_send_policy(fec_send_policy);
428 } 397 }
429 398
430 } // namespace net 399 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.h ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698