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

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

Issue 1411953005: Remove the QuicPacketGenerator from the PacketTooLarge EndToEndTest and no longer allow too large p… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@106400931
Patch Set: Created 5 years, 1 month 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 | « no previous file | net/quic/test_tools/quic_packet_creator_peer.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 bool possibly_truncated_by_length = packet_size_ == max_plaintext_size_ && 493 bool possibly_truncated_by_length = packet_size_ == max_plaintext_size_ &&
494 queued_frames_.size() == 1 && 494 queued_frames_.size() == 1 &&
495 queued_frames_.back().type == ACK_FRAME; 495 queued_frames_.back().type == ACK_FRAME;
496 // The optimized encryption algorithm implementations run faster when 496 // The optimized encryption algorithm implementations run faster when
497 // operating on aligned memory. 497 // operating on aligned memory.
498 // TODO(rtenneti): Change the default 64 alignas value (used the default 498 // TODO(rtenneti): Change the default 64 alignas value (used the default
499 // value from CACHELINE_SIZE). 499 // value from CACHELINE_SIZE).
500 ALIGNAS(64) char buffer[kMaxPacketSize]; 500 ALIGNAS(64) char buffer[kMaxPacketSize];
501 // Use the packet_size_ instead of the buffer size to ensure smaller 501 // Use the packet_size_ instead of the buffer size to ensure smaller
502 // packet sizes are properly used. 502 // packet sizes are properly used.
503 scoped_ptr<char[]> large_buffer; 503 size_t length =
504 size_t length = 0; 504 framer_->BuildDataPacket(header, queued_frames_, buffer, packet_size_);
505 const bool use_stack_buffer = packet_size_ <= kMaxPacketSize;
506 if (use_stack_buffer) {
507 length =
508 framer_->BuildDataPacket(header, queued_frames_, buffer, packet_size_);
509 } else {
510 large_buffer.reset(new char[packet_size_]);
511 length = framer_->BuildDataPacket(header, queued_frames_,
512 large_buffer.get(), packet_size_);
513 }
514 if (length == 0) { 505 if (length == 0) {
515 LOG(DFATAL) << "Failed to serialize " << queued_frames_.size() 506 LOG(DFATAL) << "Failed to serialize " << queued_frames_.size()
516 << " frames."; 507 << " frames.";
517 return NoPacket(); 508 return NoPacket();
518 } 509 }
519 510
520 // TODO(ianswett) Consider replacing QuicPacket with something else, 511 // TODO(ianswett) Consider replacing QuicPacket with something else,
521 // since it's only used to provide convenience methods to FEC and encryption. 512 // since it's only used to provide convenience methods to FEC and encryption.
522 QuicPacket packet(use_stack_buffer ? buffer : large_buffer.get(), length, 513 QuicPacket packet(buffer, length,
523 /* owns_buffer */ false, 514 /* owns_buffer */ false,
524 header.public_header.connection_id_length, 515 header.public_header.connection_id_length,
525 header.public_header.version_flag, 516 header.public_header.version_flag,
526 header.public_header.packet_number_length); 517 header.public_header.packet_number_length);
527 OnBuiltFecProtectedPayload(header, packet.FecProtectedData()); 518 OnBuiltFecProtectedPayload(header, packet.FecProtectedData());
528 519
529 // Because of possible truncation, we can't be confident that our 520 // Because of possible truncation, we can't be confident that our
530 // packet size calculation worked correctly. 521 // packet size calculation worked correctly.
531 if (!possibly_truncated_by_length) { 522 if (!possibly_truncated_by_length) {
532 DCHECK_EQ(packet_size_, length); 523 DCHECK_EQ(packet_size_, length);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 if (BytesFree() == 0) { 680 if (BytesFree() == 0) {
690 // Don't pad full packets. 681 // Don't pad full packets.
691 return; 682 return;
692 } 683 }
693 684
694 bool success = AddFrame(QuicFrame(QuicPaddingFrame()), false, false, nullptr); 685 bool success = AddFrame(QuicFrame(QuicPaddingFrame()), false, false, nullptr);
695 DCHECK(success); 686 DCHECK(success);
696 } 687 }
697 688
698 } // namespace net 689 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/test_tools/quic_packet_creator_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698