Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / quic / test_tools / quic_test_packet_maker.h
blob9120eeb7eed6ff0ee6acd232d2edc49e9bb536e7
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
3 // found in the LICENSE file.
4 //
5 // Provides a simple interface for QUIC tests to create a variety of packets.
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/request_priority.h"
12 #include "net/quic/quic_protocol.h"
13 #include "net/quic/test_tools/mock_clock.h"
14 #include "net/quic/test_tools/mock_random.h"
15 #include "net/spdy/spdy_framer.h"
16 #include "net/spdy/spdy_protocol.h"
18 namespace net {
19 namespace test {
21 class QuicTestPacketMaker {
22 public:
23 QuicTestPacketMaker(QuicVersion version,
24 QuicConnectionId connection_id,
25 MockClock* clock);
26 ~QuicTestPacketMaker();
28 scoped_ptr<QuicEncryptedPacket> MakeRstPacket(
29 QuicPacketSequenceNumber num,
30 bool include_version,
31 QuicStreamId stream_id,
32 QuicRstStreamErrorCode error_code);
33 scoped_ptr<QuicEncryptedPacket> MakeAckAndRstPacket(
34 QuicPacketSequenceNumber num,
35 bool include_version,
36 QuicStreamId stream_id,
37 QuicRstStreamErrorCode error_code,
38 QuicPacketSequenceNumber largest_received,
39 QuicPacketSequenceNumber least_unacked,
40 bool send_feedback);
41 scoped_ptr<QuicEncryptedPacket> MakeConnectionClosePacket(
42 QuicPacketSequenceNumber num);
43 scoped_ptr<QuicEncryptedPacket> MakeAckPacket(
44 QuicPacketSequenceNumber sequence_number,
45 QuicPacketSequenceNumber largest_received,
46 QuicPacketSequenceNumber least_unacked,
47 bool send_feedback);
48 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(
49 QuicPacketSequenceNumber sequence_number,
50 QuicStreamId stream_id,
51 bool should_include_version,
52 bool fin,
53 QuicStreamOffset offset,
54 base::StringPiece data);
55 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket(
56 QuicPacketSequenceNumber sequence_number,
57 QuicStreamId stream_id,
58 bool should_include_version,
59 bool fin,
60 const SpdyHeaderBlock& headers);
61 scoped_ptr<QuicEncryptedPacket> MakeResponseHeadersPacket(
62 QuicPacketSequenceNumber sequence_number,
63 QuicStreamId stream_id,
64 bool should_include_version,
65 bool fin,
66 const SpdyHeaderBlock& headers);
68 SpdyHeaderBlock GetRequestHeaders(const std::string& method,
69 const std::string& scheme,
70 const std::string& path);
71 SpdyHeaderBlock GetResponseHeaders(const std::string& status);
73 private:
74 scoped_ptr<QuicEncryptedPacket> MakePacket(
75 const QuicPacketHeader& header,
76 const QuicFrame& frame);
78 void InitializeHeader(QuicPacketSequenceNumber sequence_number,
79 bool should_include_version);
81 QuicVersion version_;
82 QuicConnectionId connection_id_;
83 MockClock* clock_; // Owned by QuicStreamFactory.
84 SpdyFramer spdy_request_framer_;
85 SpdyFramer spdy_response_framer_;
86 MockRandom random_generator_;
87 QuicPacketHeader header_;
89 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker);
92 } // namespace test
93 } // namespace net
95 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_