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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 packet_size += frame_size; | 79 packet_size += frame_size; |
80 } | 80 } |
81 return BuildUnsizedDataPacket(framer, header, frames, packet_size); | 81 return BuildUnsizedDataPacket(framer, header, frames, packet_size); |
82 } | 82 } |
83 | 83 |
84 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, | 84 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
85 const QuicPacketHeader& header, | 85 const QuicPacketHeader& header, |
86 const QuicFrames& frames, | 86 const QuicFrames& frames, |
87 size_t packet_size) { | 87 size_t packet_size) { |
88 char* buffer = new char[packet_size]; | 88 char* buffer = new char[packet_size]; |
89 scoped_ptr<QuicPacket> packet( | 89 size_t length = framer->BuildDataPacket(header, frames, buffer, packet_size); |
90 framer->BuildDataPacket(header, frames, buffer, packet_size)); | 90 DCHECK_NE(0u, length); |
91 DCHECK(packet.get() != nullptr); | 91 // Re-construct the data packet with data ownership. |
92 // Now I have to re-construct the data packet with data ownership. | 92 return new QuicPacket(buffer, length, /* owns_buffer */ true, |
93 return new QuicPacket(buffer, packet->length(), true, | |
94 header.public_header.connection_id_length, | 93 header.public_header.connection_id_length, |
95 header.public_header.version_flag, | 94 header.public_header.version_flag, |
96 header.public_header.packet_number_length); | 95 header.public_header.packet_number_length); |
97 } | 96 } |
98 | 97 |
99 uint64 SimpleRandom::RandUint64() { | 98 uint64 SimpleRandom::RandUint64() { |
100 unsigned char hash[base::kSHA1Length]; | 99 unsigned char hash[base::kSHA1Length]; |
101 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), | 100 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), |
102 hash); | 101 hash); |
103 memcpy(&seed_, hash, sizeof(seed_)); | 102 memcpy(&seed_, hash, sizeof(seed_)); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 // strike register worries that we've just overflowed a uint32 time. | 818 // strike register worries that we've just overflowed a uint32 time. |
820 (*server_connection)->AdvanceTime(connection_start_time); | 819 (*server_connection)->AdvanceTime(connection_start_time); |
821 } | 820 } |
822 | 821 |
823 QuicStreamId QuicClientDataStreamId(int i) { | 822 QuicStreamId QuicClientDataStreamId(int i) { |
824 return kClientDataStreamId1 + 2 * i; | 823 return kClientDataStreamId1 + 2 * i; |
825 } | 824 } |
826 | 825 |
827 } // namespace test | 826 } // namespace test |
828 } // namespace net | 827 } // namespace net |
OLD | NEW |