| 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 14 matching lines...) Expand all Loading... |
| 57 QuicPacketNumber packet_number, | 59 QuicPacketNumber packet_number, |
| 58 QuicPacketNumber largest_received, | 60 QuicPacketNumber largest_received, |
| 59 QuicPacketNumber least_unacked, | 61 QuicPacketNumber least_unacked, |
| 60 bool send_feedback); | 62 bool send_feedback); |
| 61 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(QuicPacketNumber packet_number, | 63 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(QuicPacketNumber packet_number, |
| 62 QuicStreamId stream_id, | 64 QuicStreamId stream_id, |
| 63 bool should_include_version, | 65 bool should_include_version, |
| 64 bool fin, | 66 bool fin, |
| 65 QuicStreamOffset offset, | 67 QuicStreamOffset offset, |
| 66 base::StringPiece data); | 68 base::StringPiece data); |
| 69 scoped_ptr<QuicEncryptedPacket> MakeAckAndDataPacket( |
| 70 QuicPacketNumber packet_number, |
| 71 bool include_version, |
| 72 QuicStreamId stream_id, |
| 73 QuicPacketNumber largest_received, |
| 74 QuicPacketNumber least_unacked, |
| 75 bool fin, |
| 76 QuicStreamOffset offset, |
| 77 base::StringPiece data); |
| 67 | 78 |
| 68 // If |spdy_headers_frame_length| is non-null, it will be set to the size of | 79 // If |spdy_headers_frame_length| is non-null, it will be set to the size of |
| 69 // the SPDY headers frame created for this packet. | 80 // the SPDY headers frame created for this packet. |
| 70 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket( | 81 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket( |
| 71 QuicPacketNumber packet_number, | 82 QuicPacketNumber packet_number, |
| 72 QuicStreamId stream_id, | 83 QuicStreamId stream_id, |
| 73 bool should_include_version, | 84 bool should_include_version, |
| 74 bool fin, | 85 bool fin, |
| 75 SpdyPriority priority, | 86 SpdyPriority priority, |
| 76 const SpdyHeaderBlock& headers, | 87 const SpdyHeaderBlock& headers, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 106 const SpdyHeaderBlock& headers); | 117 const SpdyHeaderBlock& headers); |
| 107 | 118 |
| 108 SpdyHeaderBlock GetRequestHeaders(const std::string& method, | 119 SpdyHeaderBlock GetRequestHeaders(const std::string& method, |
| 109 const std::string& scheme, | 120 const std::string& scheme, |
| 110 const std::string& path); | 121 const std::string& path); |
| 111 SpdyHeaderBlock GetResponseHeaders(const std::string& status); | 122 SpdyHeaderBlock GetResponseHeaders(const std::string& status); |
| 112 | 123 |
| 113 private: | 124 private: |
| 114 scoped_ptr<QuicEncryptedPacket> MakePacket(const QuicPacketHeader& header, | 125 scoped_ptr<QuicEncryptedPacket> MakePacket(const QuicPacketHeader& header, |
| 115 const QuicFrame& frame); | 126 const QuicFrame& frame); |
| 127 scoped_ptr<QuicEncryptedPacket> MakeMultipleFramesPacket( |
| 128 const QuicPacketHeader& header, |
| 129 const QuicFrames& frames); |
| 116 | 130 |
| 117 void InitializeHeader(QuicPacketNumber packet_number, | 131 void InitializeHeader(QuicPacketNumber packet_number, |
| 118 bool should_include_version); | 132 bool should_include_version); |
| 119 | 133 |
| 120 QuicVersion version_; | 134 QuicVersion version_; |
| 121 QuicConnectionId connection_id_; | 135 QuicConnectionId connection_id_; |
| 122 MockClock* clock_; // Owned by QuicStreamFactory. | 136 MockClock* clock_; // Owned by QuicStreamFactory. |
| 123 std::string host_; | 137 std::string host_; |
| 124 SpdyFramer spdy_request_framer_; | 138 SpdyFramer spdy_request_framer_; |
| 125 SpdyFramer spdy_response_framer_; | 139 SpdyFramer spdy_response_framer_; |
| 126 MockRandom random_generator_; | 140 MockRandom random_generator_; |
| 127 QuicPacketHeader header_; | 141 QuicPacketHeader header_; |
| 128 | 142 |
| 129 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker); | 143 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker); |
| 130 }; | 144 }; |
| 131 | 145 |
| 132 } // namespace test | 146 } // namespace test |
| 133 } // namespace net | 147 } // namespace net |
| 134 | 148 |
| 135 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ | 149 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_ |
| OLD | NEW |