Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / quic / test_tools / quic_test_packet_maker.h
blob1026e6c73dff76e517f5d2eca4b36832329c6c0f
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 const std::string& host);
27 ~QuicTestPacketMaker();
29 void set_hostname(const std::string& host);
30 scoped_ptr<QuicEncryptedPacket> MakeRstPacket(
31 QuicPacketNumber num,
32 bool include_version,
33 QuicStreamId stream_id,
34 QuicRstStreamErrorCode error_code);
35 scoped_ptr<QuicEncryptedPacket> MakeAckAndRstPacket(
36 QuicPacketNumber num,
37 bool include_version,
38 QuicStreamId stream_id,
39 QuicRstStreamErrorCode error_code,
40 QuicPacketNumber largest_received,
41 QuicPacketNumber least_unacked,
42 bool send_feedback);
43 scoped_ptr<QuicEncryptedPacket> MakeConnectionClosePacket(
44 QuicPacketNumber num);
45 scoped_ptr<QuicEncryptedPacket> MakeAckPacket(
46 QuicPacketNumber packet_number,
47 QuicPacketNumber largest_received,
48 QuicPacketNumber least_unacked,
49 bool send_feedback);
50 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(QuicPacketNumber packet_number,
51 QuicStreamId stream_id,
52 bool should_include_version,
53 bool fin,
54 QuicStreamOffset offset,
55 base::StringPiece data);
56 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket(
57 QuicPacketNumber packet_number,
58 QuicStreamId stream_id,
59 bool should_include_version,
60 bool fin,
61 QuicPriority priority,
62 const SpdyHeaderBlock& headers);
63 scoped_ptr<QuicEncryptedPacket> MakeResponseHeadersPacket(
64 QuicPacketNumber packet_number,
65 QuicStreamId stream_id,
66 bool should_include_version,
67 bool fin,
68 const SpdyHeaderBlock& headers);
70 SpdyHeaderBlock GetRequestHeaders(const std::string& method,
71 const std::string& scheme,
72 const std::string& path);
73 SpdyHeaderBlock GetResponseHeaders(const std::string& status);
75 private:
76 scoped_ptr<QuicEncryptedPacket> MakePacket(
77 const QuicPacketHeader& header,
78 const QuicFrame& frame);
80 void InitializeHeader(QuicPacketNumber packet_number,
81 bool should_include_version);
83 QuicVersion version_;
84 QuicConnectionId connection_id_;
85 MockClock* clock_; // Owned by QuicStreamFactory.
86 std::string host_;
87 SpdyFramer spdy_request_framer_;
88 SpdyFramer spdy_response_framer_;
89 MockRandom random_generator_;
90 QuicPacketHeader header_;
92 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker);
95 } // namespace test
96 } // namespace net
98 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_