| OLD | NEW |
| 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/sha1.h" | 7 #include "base/sha1.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/quic/crypto/crypto_framer.h" | 10 #include "net/quic/crypto/crypto_framer.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const QuicPacketHeader& header, | 54 const QuicPacketHeader& header, |
| 55 const QuicFrames& frames) { | 55 const QuicFrames& frames) { |
| 56 const size_t max_plaintext_size = framer->GetMaxPlaintextSize(kMaxPacketSize); | 56 const size_t max_plaintext_size = framer->GetMaxPlaintextSize(kMaxPacketSize); |
| 57 size_t packet_size = GetPacketHeaderSize(header); | 57 size_t packet_size = GetPacketHeaderSize(header); |
| 58 for (size_t i = 0; i < frames.size(); ++i) { | 58 for (size_t i = 0; i < frames.size(); ++i) { |
| 59 DCHECK_LE(packet_size, max_plaintext_size); | 59 DCHECK_LE(packet_size, max_plaintext_size); |
| 60 bool first_frame = i == 0; | 60 bool first_frame = i == 0; |
| 61 bool last_frame = i == frames.size() - 1; | 61 bool last_frame = i == frames.size() - 1; |
| 62 const size_t frame_size = framer->GetSerializedFrameLength( | 62 const size_t frame_size = framer->GetSerializedFrameLength( |
| 63 frames[i], max_plaintext_size - packet_size, first_frame, last_frame, | 63 frames[i], max_plaintext_size - packet_size, first_frame, last_frame, |
| 64 header.is_in_fec_group, header.public_header.packet_number_length); | 64 header.public_header.packet_number_length); |
| 65 DCHECK(frame_size); | 65 DCHECK(frame_size); |
| 66 packet_size += frame_size; | 66 packet_size += frame_size; |
| 67 } | 67 } |
| 68 return BuildUnsizedDataPacket(framer, header, frames, packet_size); | 68 return BuildUnsizedDataPacket(framer, header, frames, packet_size); |
| 69 } | 69 } |
| 70 | 70 |
| 71 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, | 71 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
| 72 const QuicPacketHeader& header, | 72 const QuicPacketHeader& header, |
| 73 const QuicFrames& frames, | 73 const QuicFrames& frames, |
| 74 size_t packet_size) { | 74 size_t packet_size) { |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 CryptoHandshakeMessage message; | 665 CryptoHandshakeMessage message; |
| 666 message.set_tag(tag); | 666 message.set_tag(tag); |
| 667 return ConstructPacketFromHandshakeMessage(connection_id, message, false); | 667 return ConstructPacketFromHandshakeMessage(connection_id, message, false); |
| 668 } | 668 } |
| 669 | 669 |
| 670 size_t GetPacketLengthForOneStream(QuicVersion version, | 670 size_t GetPacketLengthForOneStream(QuicVersion version, |
| 671 bool include_version, | 671 bool include_version, |
| 672 bool include_path_id, | 672 bool include_path_id, |
| 673 QuicConnectionIdLength connection_id_length, | 673 QuicConnectionIdLength connection_id_length, |
| 674 QuicPacketNumberLength packet_number_length, | 674 QuicPacketNumberLength packet_number_length, |
| 675 InFecGroup is_in_fec_group, | |
| 676 size_t* payload_length) { | 675 size_t* payload_length) { |
| 677 *payload_length = 1; | 676 *payload_length = 1; |
| 678 const size_t stream_length = | 677 const size_t stream_length = |
| 679 NullEncrypter().GetCiphertextSize(*payload_length) + | 678 NullEncrypter().GetCiphertextSize(*payload_length) + |
| 680 QuicPacketCreator::StreamFramePacketOverhead( | 679 QuicPacketCreator::StreamFramePacketOverhead( |
| 681 PACKET_8BYTE_CONNECTION_ID, include_version, include_path_id, | 680 PACKET_8BYTE_CONNECTION_ID, include_version, include_path_id, |
| 682 packet_number_length, 0u, is_in_fec_group); | 681 packet_number_length, 0u); |
| 683 const size_t ack_length = | 682 const size_t ack_length = |
| 684 NullEncrypter().GetCiphertextSize( | 683 NullEncrypter().GetCiphertextSize( |
| 685 QuicFramer::GetMinAckFrameSize(PACKET_1BYTE_PACKET_NUMBER)) + | 684 QuicFramer::GetMinAckFrameSize(PACKET_1BYTE_PACKET_NUMBER)) + |
| 686 GetPacketHeaderSize(connection_id_length, include_version, | 685 GetPacketHeaderSize(connection_id_length, include_version, |
| 687 include_path_id, packet_number_length, | 686 include_path_id, packet_number_length); |
| 688 is_in_fec_group); | |
| 689 if (stream_length < ack_length) { | 687 if (stream_length < ack_length) { |
| 690 *payload_length = 1 + ack_length - stream_length; | 688 *payload_length = 1 + ack_length - stream_length; |
| 691 } | 689 } |
| 692 | 690 |
| 693 return NullEncrypter().GetCiphertextSize(*payload_length) + | 691 return NullEncrypter().GetCiphertextSize(*payload_length) + |
| 694 QuicPacketCreator::StreamFramePacketOverhead( | 692 QuicPacketCreator::StreamFramePacketOverhead( |
| 695 connection_id_length, include_version, include_path_id, | 693 connection_id_length, include_version, include_path_id, |
| 696 packet_number_length, 0u, is_in_fec_group); | 694 packet_number_length, 0u); |
| 697 } | 695 } |
| 698 | 696 |
| 699 TestEntropyCalculator::TestEntropyCalculator() {} | 697 TestEntropyCalculator::TestEntropyCalculator() {} |
| 700 | 698 |
| 701 TestEntropyCalculator::~TestEntropyCalculator() {} | 699 TestEntropyCalculator::~TestEntropyCalculator() {} |
| 702 | 700 |
| 703 QuicPacketEntropyHash TestEntropyCalculator::EntropyHash( | 701 QuicPacketEntropyHash TestEntropyCalculator::EntropyHash( |
| 704 QuicPacketNumber packet_number) const { | 702 QuicPacketNumber packet_number) const { |
| 705 return 1u; | 703 return 1u; |
| 706 } | 704 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 // strike register worries that we've just overflowed a uint32_t time. | 787 // strike register worries that we've just overflowed a uint32_t time. |
| 790 (*server_connection)->AdvanceTime(connection_start_time); | 788 (*server_connection)->AdvanceTime(connection_start_time); |
| 791 } | 789 } |
| 792 | 790 |
| 793 QuicStreamId QuicClientDataStreamId(int i) { | 791 QuicStreamId QuicClientDataStreamId(int i) { |
| 794 return kClientDataStreamId1 + 2 * i; | 792 return kClientDataStreamId1 + 2 * i; |
| 795 } | 793 } |
| 796 | 794 |
| 797 } // namespace test | 795 } // namespace test |
| 798 } // namespace net | 796 } // namespace net |
| OLD | NEW |