| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Provides a simple interface for QUIC tests to create a variety of packets. | 5 // Provides a simple interface for QUIC tests to create a variety of packets. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ |
| 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class QuicTestPacketMaker { | 24 class QuicTestPacketMaker { |
| 25 public: | 25 public: |
| 26 QuicTestPacketMaker(QuicVersion version, | 26 QuicTestPacketMaker(QuicVersion version, |
| 27 QuicConnectionId connection_id, | 27 QuicConnectionId connection_id, |
| 28 MockClock* clock, | 28 MockClock* clock, |
| 29 const std::string& host); | 29 const std::string& host); |
| 30 ~QuicTestPacketMaker(); | 30 ~QuicTestPacketMaker(); |
| 31 | 31 |
| 32 void set_hostname(const std::string& host); | 32 void set_hostname(const std::string& host); |
| 33 scoped_ptr<QuicEncryptedPacket> MakePingPacket(QuicPacketNumber num, |
| 34 bool include_version); |
| 33 scoped_ptr<QuicEncryptedPacket> MakeRstPacket( | 35 scoped_ptr<QuicEncryptedPacket> MakeRstPacket( |
| 34 QuicPacketNumber num, | 36 QuicPacketNumber num, |
| 35 bool include_version, | 37 bool include_version, |
| 36 QuicStreamId stream_id, | 38 QuicStreamId stream_id, |
| 37 QuicRstStreamErrorCode error_code); | 39 QuicRstStreamErrorCode error_code); |
| 38 scoped_ptr<QuicEncryptedPacket> MakeAckAndRstPacket( | 40 scoped_ptr<QuicEncryptedPacket> MakeAckAndRstPacket( |
| 39 QuicPacketNumber num, | 41 QuicPacketNumber num, |
| 40 bool include_version, | 42 bool include_version, |
| 41 QuicStreamId stream_id, | 43 QuicStreamId stream_id, |
| 42 QuicRstStreamErrorCode error_code, | 44 QuicRstStreamErrorCode error_code, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 QuicPacketNumber largest_received, | 65 QuicPacketNumber largest_received, |
| 64 QuicPacketNumber ack_least_unacked, | 66 QuicPacketNumber ack_least_unacked, |
| 65 QuicPacketNumber stop_least_unacked, | 67 QuicPacketNumber stop_least_unacked, |
| 66 bool send_feedback); | 68 bool send_feedback); |
| 67 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(QuicPacketNumber packet_number, | 69 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(QuicPacketNumber packet_number, |
| 68 QuicStreamId stream_id, | 70 QuicStreamId stream_id, |
| 69 bool should_include_version, | 71 bool should_include_version, |
| 70 bool fin, | 72 bool fin, |
| 71 QuicStreamOffset offset, | 73 QuicStreamOffset offset, |
| 72 base::StringPiece data); | 74 base::StringPiece data); |
| 75 scoped_ptr<QuicEncryptedPacket> MakeAckAndDataPacket( |
| 76 QuicPacketNumber packet_number, |
| 77 bool include_version, |
| 78 QuicStreamId stream_id, |
| 79 QuicPacketNumber largest_received, |
| 80 QuicPacketNumber least_unacked, |
| 81 bool fin, |
| 82 QuicStreamOffset offset, |
| 83 base::StringPiece data); |
| 73 | 84 |
| 74 // If |spdy_headers_frame_length| is non-null, it will be set to the size of | 85 // If |spdy_headers_frame_length| is non-null, it will be set to the size of |
| 75 // the SPDY headers frame created for this packet. | 86 // the SPDY headers frame created for this packet. |
| 76 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket( | 87 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket( |
| 77 QuicPacketNumber packet_number, | 88 QuicPacketNumber packet_number, |
| 78 QuicStreamId stream_id, | 89 QuicStreamId stream_id, |
| 79 bool should_include_version, | 90 bool should_include_version, |
| 80 bool fin, | 91 bool fin, |
| 81 SpdyPriority priority, | 92 SpdyPriority priority, |
| 82 const SpdyHeaderBlock& headers, | 93 const SpdyHeaderBlock& headers, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const std::string& scheme, | 147 const std::string& scheme, |
| 137 const std::string& path); | 148 const std::string& path); |
| 138 SpdyHeaderBlock GetResponseHeaders(const std::string& status); | 149 SpdyHeaderBlock GetResponseHeaders(const std::string& status); |
| 139 | 150 |
| 140 SpdyHeaderBlock GetResponseHeaders(const std::string& status, | 151 SpdyHeaderBlock GetResponseHeaders(const std::string& status, |
| 141 const std::string& alt_svc); | 152 const std::string& alt_svc); |
| 142 | 153 |
| 143 private: | 154 private: |
| 144 scoped_ptr<QuicEncryptedPacket> MakePacket(const QuicPacketHeader& header, | 155 scoped_ptr<QuicEncryptedPacket> MakePacket(const QuicPacketHeader& header, |
| 145 const QuicFrame& frame); | 156 const QuicFrame& frame); |
| 157 scoped_ptr<QuicEncryptedPacket> MakeMultipleFramesPacket( |
| 158 const QuicPacketHeader& header, |
| 159 const QuicFrames& frames); |
| 146 | 160 |
| 147 void InitializeHeader(QuicPacketNumber packet_number, | 161 void InitializeHeader(QuicPacketNumber packet_number, |
| 148 bool should_include_version); | 162 bool should_include_version); |
| 149 | 163 |
| 150 QuicVersion version_; | 164 QuicVersion version_; |
| 151 QuicConnectionId connection_id_; | 165 QuicConnectionId connection_id_; |
| 152 MockClock* clock_; // Owned by QuicStreamFactory. | 166 MockClock* clock_; // Owned by QuicStreamFactory. |
| 153 std::string host_; | 167 std::string host_; |
| 154 SpdyFramer spdy_request_framer_; | 168 SpdyFramer spdy_request_framer_; |
| 155 SpdyFramer spdy_response_framer_; | 169 SpdyFramer spdy_response_framer_; |
| 156 MockRandom random_generator_; | 170 MockRandom random_generator_; |
| 157 QuicPacketHeader header_; | 171 QuicPacketHeader header_; |
| 158 | 172 |
| 159 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker); | 173 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker); |
| 160 }; | 174 }; |
| 161 | 175 |
| 162 } // namespace test | 176 } // namespace test |
| 163 } // namespace net | 177 } // namespace net |
| 164 | 178 |
| 165 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ | 179 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ |
| OLD | NEW |