Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / quic / test_tools / quic_test_packet_maker.h
blob23eb85642f2aa450992bb29e7fe148a7f7bd1399
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 QuicPacketSequenceNumber num,
32 bool include_version,
33 QuicStreamId stream_id,
34 QuicRstStreamErrorCode error_code);
35 scoped_ptr<QuicEncryptedPacket> MakeAckAndRstPacket(
36 QuicPacketSequenceNumber num,
37 bool include_version,
38 QuicStreamId stream_id,
39 QuicRstStreamErrorCode error_code,
40 QuicPacketSequenceNumber largest_received,
41 QuicPacketSequenceNumber least_unacked,
42 bool send_feedback);
43 scoped_ptr<QuicEncryptedPacket> MakeConnectionClosePacket(
44 QuicPacketSequenceNumber num);
45 scoped_ptr<QuicEncryptedPacket> MakeAckPacket(
46 QuicPacketSequenceNumber sequence_number,
47 QuicPacketSequenceNumber largest_received,
48 QuicPacketSequenceNumber least_unacked,
49 bool send_feedback);
50 scoped_ptr<QuicEncryptedPacket> MakeDataPacket(
51 QuicPacketSequenceNumber sequence_number,
52 QuicStreamId stream_id,
53 bool should_include_version,
54 bool fin,
55 QuicStreamOffset offset,
56 base::StringPiece data);
57 scoped_ptr<QuicEncryptedPacket> MakeRequestHeadersPacket(
58 QuicPacketSequenceNumber sequence_number,
59 QuicStreamId stream_id,
60 bool should_include_version,
61 bool fin,
62 QuicPriority priority,
63 const SpdyHeaderBlock& headers);
64 scoped_ptr<QuicEncryptedPacket> MakeResponseHeadersPacket(
65 QuicPacketSequenceNumber sequence_number,
66 QuicStreamId stream_id,
67 bool should_include_version,
68 bool fin,
69 const SpdyHeaderBlock& headers);
71 SpdyHeaderBlock GetRequestHeaders(const std::string& method,
72 const std::string& scheme,
73 const std::string& path);
74 SpdyHeaderBlock GetResponseHeaders(const std::string& status);
76 private:
77 scoped_ptr<QuicEncryptedPacket> MakePacket(
78 const QuicPacketHeader& header,
79 const QuicFrame& frame);
81 void InitializeHeader(QuicPacketSequenceNumber sequence_number,
82 bool should_include_version);
84 QuicVersion version_;
85 QuicConnectionId connection_id_;
86 MockClock* clock_; // Owned by QuicStreamFactory.
87 std::string host_;
88 SpdyFramer spdy_request_framer_;
89 SpdyFramer spdy_response_framer_;
90 MockRandom random_generator_;
91 QuicPacketHeader header_;
93 DISALLOW_COPY_AND_ASSIGN(QuicTestPacketMaker);
96 } // namespace test
97 } // namespace net
99 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_PACKET_MAKER_H_