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

Side by Side Diff: net/quic/test_tools/quic_test_utils.cc

Issue 18307003: Implement the variable length changes necessary to easily accommodate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with TOT Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | 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/test_tools/quic_test_utils.h" 5 #include "net/quic/test_tools/quic_test_utils.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/crypto_framer.h" 8 #include "net/quic/crypto/crypto_framer.h"
9 #include "net/quic/crypto/crypto_handshake.h" 9 #include "net/quic/crypto/crypto_handshake.h"
10 #include "net/quic/crypto/crypto_utils.h" 10 #include "net/quic/crypto/crypto_utils.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return quic_framer.ConstructFrameDataPacket(header, frames).packet; 375 return quic_framer.ConstructFrameDataPacket(header, frames).packet;
376 } 376 }
377 377
378 QuicPacket* ConstructHandshakePacket(QuicGuid guid, QuicTag tag) { 378 QuicPacket* ConstructHandshakePacket(QuicGuid guid, QuicTag tag) {
379 CryptoHandshakeMessage message; 379 CryptoHandshakeMessage message;
380 message.set_tag(tag); 380 message.set_tag(tag);
381 return ConstructPacketFromHandshakeMessage(guid, message, false); 381 return ConstructPacketFromHandshakeMessage(guid, message, false);
382 } 382 }
383 383
384 size_t GetPacketLengthForOneStream( 384 size_t GetPacketLengthForOneStream(
385 bool include_version, InFecGroup is_in_fec_group, size_t payload) { 385 bool include_version, InFecGroup is_in_fec_group, size_t* payload_length) {
386 // TODO(wtc): the hardcoded use of NullEncrypter here seems wrong. 386 *payload_length = 1;
387 size_t packet_length = NullEncrypter().GetCiphertextSize(payload) + 387 const size_t stream_length =
388 NullEncrypter().GetCiphertextSize(*payload_length) +
388 QuicPacketCreator::StreamFramePacketOverhead( 389 QuicPacketCreator::StreamFramePacketOverhead(
389 1, PACKET_8BYTE_GUID, include_version, 390 PACKET_8BYTE_GUID, include_version,
390 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group); 391 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group);
391 392 const size_t ack_length = NullEncrypter().GetCiphertextSize(
392 size_t ack_length = NullEncrypter().GetCiphertextSize(
393 QuicFramer::GetMinAckFrameSize()) + 393 QuicFramer::GetMinAckFrameSize()) +
394 GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version, 394 GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version,
395 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group); 395 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group);
396 // Make sure that if we change the size of the packet length for one stream 396 if (stream_length < ack_length) {
397 // or the ack frame; that all our test are configured correctly. 397 *payload_length = 1 + ack_length - stream_length;
398 DCHECK_GE(packet_length, ack_length); 398 }
399 return packet_length; 399
400 return NullEncrypter().GetCiphertextSize(*payload_length) +
401 QuicPacketCreator::StreamFramePacketOverhead(
402 PACKET_8BYTE_GUID, include_version,
403 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group);
400 } 404 }
401 405
402 QuicPacketEntropyHash TestEntropyCalculator::ReceivedEntropyHash( 406 QuicPacketEntropyHash TestEntropyCalculator::ReceivedEntropyHash(
403 QuicPacketSequenceNumber sequence_number) const { 407 QuicPacketSequenceNumber sequence_number) const {
404 return 1u; 408 return 1u;
405 } 409 }
406 410
407 QuicConfig DefaultQuicConfig() { 411 QuicConfig DefaultQuicConfig() {
408 QuicConfig config; 412 QuicConfig config;
409 config.SetDefaults(); 413 config.SetDefaults();
410 return config; 414 return config;
411 } 415 }
412 416
413 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) { 417 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) {
414 data.AppendToString(&data_); 418 data.AppendToString(&data_);
415 return true; 419 return true;
416 } 420 }
417 421
418 void TestDecompressorVisitor::OnDecompressionError() { 422 void TestDecompressorVisitor::OnDecompressionError() {
419 error_ = true; 423 error_ = true;
420 } 424 }
421 425
422 } // namespace test 426 } // namespace test
423 } // namespace net 427 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698