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

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

Issue 478153003: Change the wire format of the ack frame to include a compressed version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase TOT and pass clock to QuicTestPacketMaker and use it in AckPacket Created 6 years, 3 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/quic_network_transaction_unittest.cc ('k') | net/quic/quic_protocol.h » ('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_creator.h" 5 #include "net/quic/quic_packet_creator.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/crypto/quic_random.h" 9 #include "net/quic/crypto/quic_random.h"
10 #include "net/quic/quic_ack_notifier.h" 10 #include "net/quic/quic_ack_notifier.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 << "Attempt to serialize empty packet"; 372 << "Attempt to serialize empty packet";
373 DCHECK_GE(sequence_number_ + 1, fec_group_number_); 373 DCHECK_GE(sequence_number_ + 1, fec_group_number_);
374 QuicPacketHeader header; 374 QuicPacketHeader header;
375 FillPacketHeader(should_fec_protect_ ? fec_group_number_ : 0, false, &header); 375 FillPacketHeader(should_fec_protect_ ? fec_group_number_ : 0, false, &header);
376 376
377 MaybeAddPadding(); 377 MaybeAddPadding();
378 378
379 size_t max_plaintext_size = 379 size_t max_plaintext_size =
380 framer_->GetMaxPlaintextSize(max_packet_length_); 380 framer_->GetMaxPlaintextSize(max_packet_length_);
381 DCHECK_GE(max_plaintext_size, packet_size_); 381 DCHECK_GE(max_plaintext_size, packet_size_);
382 // ACK Frames will be truncated only if they're the only frame in the packet, 382 // ACK Frames will be truncated due to length only if they're the only frame
383 // and if packet_size_ was set to max_plaintext_size. If truncation occurred, 383 // in the packet, and if packet_size_ was set to max_plaintext_size. If
384 // then GetSerializedFrameLength will have returned all bytes free. 384 // truncation due to length occurred, then GetSerializedFrameLength will have
385 bool possibly_truncated = packet_size_ == max_plaintext_size && 385 // returned all bytes free.
386 queued_frames_.size() == 1 && 386 bool possibly_truncated_by_length = packet_size_ == max_plaintext_size &&
387 queued_frames_.back().type == ACK_FRAME; 387 queued_frames_.size() == 1 &&
388 queued_frames_.back().type == ACK_FRAME;
388 SerializedPacket serialized = 389 SerializedPacket serialized =
389 framer_->BuildDataPacket(header, queued_frames_, packet_size_); 390 framer_->BuildDataPacket(header, queued_frames_, packet_size_);
390 LOG_IF(DFATAL, !serialized.packet) 391 LOG_IF(DFATAL, !serialized.packet)
391 << "Failed to serialize " << queued_frames_.size() << " frames."; 392 << "Failed to serialize " << queued_frames_.size() << " frames.";
392 // Because of possible truncation, we can't be confident that our 393 // Because of possible truncation, we can't be confident that our
393 // packet size calculation worked correctly. 394 // packet size calculation worked correctly.
394 if (!possibly_truncated) { 395 if (!possibly_truncated_by_length) {
395 DCHECK_EQ(packet_size_, serialized.packet->length()); 396 DCHECK_EQ(packet_size_, serialized.packet->length());
396 } 397 }
397 packet_size_ = 0; 398 packet_size_ = 0;
398 queued_frames_.clear(); 399 queued_frames_.clear();
399 serialized.retransmittable_frames = queued_retransmittable_frames_.release(); 400 serialized.retransmittable_frames = queued_retransmittable_frames_.release();
400 return serialized; 401 return serialized;
401 } 402 }
402 403
403 SerializedPacket QuicPacketCreator::SerializeFec() { 404 SerializedPacket QuicPacketCreator::SerializeFec() {
404 if (fec_group_.get() == NULL || fec_group_->NumReceivedPackets() <= 0) { 405 if (fec_group_.get() == NULL || fec_group_->NumReceivedPackets() <= 0) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 if (BytesFree() == 0) { 512 if (BytesFree() == 0) {
512 // Don't pad full packets. 513 // Don't pad full packets.
513 return; 514 return;
514 } 515 }
515 QuicPaddingFrame padding; 516 QuicPaddingFrame padding;
516 bool success = AddFrame(QuicFrame(&padding), false); 517 bool success = AddFrame(QuicFrame(&padding), false);
517 DCHECK(success); 518 DCHECK(success);
518 } 519 }
519 520
520 } // namespace net 521 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_network_transaction_unittest.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698