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

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

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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/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_utils.h" 11 #include "net/quic/quic_utils.h"
11 12
12 using base::StringPiece; 13 using base::StringPiece;
13 14
14 namespace net { 15 namespace net {
15 16
16 namespace { 17 namespace {
17 18
18 // We want to put some space between a protected packet and the FEC packet to 19 // We want to put some space between a protected packet and the FEC packet to
19 // avoid losing them both within the same loss episode. On the other hand, 20 // avoid losing them both within the same loss episode. On the other hand,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 void QuicPacketGenerator::OnCongestionWindowChange( 88 void QuicPacketGenerator::OnCongestionWindowChange(
88 QuicPacketCount max_packets_in_flight) { 89 QuicPacketCount max_packets_in_flight) {
89 packet_creator_.set_max_packets_per_fec_group( 90 packet_creator_.set_max_packets_per_fec_group(
90 static_cast<size_t>(kMaxPacketsInFlightMultiplierForFecGroupSize * 91 static_cast<size_t>(kMaxPacketsInFlightMultiplierForFecGroupSize *
91 max_packets_in_flight)); 92 max_packets_in_flight));
92 } 93 }
93 94
94 void QuicPacketGenerator::SetShouldSendAck(bool also_send_feedback, 95 void QuicPacketGenerator::SetShouldSendAck(bool also_send_feedback,
95 bool also_send_stop_waiting) { 96 bool also_send_stop_waiting) {
97 if (FLAGS_quic_disallow_multiple_pending_ack_frames) {
98 if (pending_ack_frame_ != nullptr) {
99 // Ack already queued, nothing to do.
100 return;
101 }
102
103 if (also_send_feedback && pending_feedback_frame_ != nullptr) {
104 LOG(DFATAL) << "Should only ever be one pending feedback frame.";
105 return;
106 }
107
108 if (also_send_stop_waiting && pending_stop_waiting_frame_ != nullptr) {
109 LOG(DFATAL) << "Should only ever be one pending stop waiting frame.";
110 return;
111 }
112 }
113
96 should_send_ack_ = true; 114 should_send_ack_ = true;
97 should_send_feedback_ = also_send_feedback; 115 should_send_feedback_ = also_send_feedback;
98 should_send_stop_waiting_ = also_send_stop_waiting; 116 should_send_stop_waiting_ = also_send_stop_waiting;
99 SendQueuedFrames(false); 117 SendQueuedFrames(false);
100 } 118 }
101 119
102 void QuicPacketGenerator::SetShouldSendStopWaiting() { 120 void QuicPacketGenerator::SetShouldSendStopWaiting() {
103 should_send_stop_waiting_ = true; 121 should_send_stop_waiting_ = true;
104 SendQueuedFrames(false); 122 SendQueuedFrames(false);
105 } 123 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 debug_delegate_->OnFrameAddedToPacket(frame); 358 debug_delegate_->OnFrameAddedToPacket(frame);
341 } 359 }
342 return success; 360 return success;
343 } 361 }
344 362
345 void QuicPacketGenerator::SerializeAndSendPacket() { 363 void QuicPacketGenerator::SerializeAndSendPacket() {
346 SerializedPacket serialized_packet = packet_creator_.SerializePacket(); 364 SerializedPacket serialized_packet = packet_creator_.SerializePacket();
347 DCHECK(serialized_packet.packet); 365 DCHECK(serialized_packet.packet);
348 delegate_->OnSerializedPacket(serialized_packet); 366 delegate_->OnSerializedPacket(serialized_packet);
349 MaybeSendFecPacketAndCloseGroup(false); 367 MaybeSendFecPacketAndCloseGroup(false);
368
369 // The packet has now been serialized, safe to delete pending frames.
370 if (FLAGS_quic_disallow_multiple_pending_ack_frames) {
371 pending_ack_frame_.reset();
372 pending_feedback_frame_.reset();
373 pending_stop_waiting_frame_.reset();
374 }
350 } 375 }
351 376
352 void QuicPacketGenerator::StopSendingVersion() { 377 void QuicPacketGenerator::StopSendingVersion() {
353 packet_creator_.StopSendingVersion(); 378 packet_creator_.StopSendingVersion();
354 } 379 }
355 380
356 QuicPacketSequenceNumber QuicPacketGenerator::sequence_number() const { 381 QuicPacketSequenceNumber QuicPacketGenerator::sequence_number() const {
357 return packet_creator_.sequence_number(); 382 return packet_creator_.sequence_number();
358 } 383 }
359 384
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); 419 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID);
395 } 420 }
396 } 421 }
397 422
398 423
399 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { 424 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) {
400 packet_creator_.set_encryption_level(level); 425 packet_creator_.set_encryption_level(level);
401 } 426 }
402 427
403 } // namespace net 428 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698