We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / quic / test_tools / quic_test_packet_maker.h
blob6a75e7cf8d4ab0205871432b8d912276d93699dd
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 QuicPriority priority,
61 const SpdyHeaderBlock& headers);
62 scoped_ptr<QuicEncryptedPacket> MakeResponseHeadersPacket(
63 QuicPacketSequenceNumber sequence_number,
64 QuicStreamId stream_id,
65 bool should_include_version,
66 bool fin,
67 const SpdyHeaderBlock& headers);
69 SpdyHeaderBlock GetRequestHeaders(const std::string& method,
70 const std::string& scheme,
71 const std::string& path);
72 SpdyHeaderBlock GetResponseHeaders(const std::string& status);
74 private:
75 scoped_ptr<QuicEncryptedPacket> MakePacket(
76 const QuicPacketHeader& header,
77 const QuicFrame& frame);
79 void InitializeHeader(QuicPacketSequenceNumber sequence_number,
80 bool should_include_version);
82 QuicVersion version_;
83 QuicConnectionId connection_id_;
84 MockClock* clock_; // Owned by QuicStreamFactory.
85 SpdyFramer spdy_request_framer_;
86 SpdyFramer spdy_response_framer_;
87 MockRandom random_generator_;
88 QuicPacketHeader header_;
90 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker);
93 } // namespace test
94 } // namespace net
96 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_