blob: 31cbd80700b4801e05a3220ef73837ffcb2da7cb [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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#ifndef QUICHE_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_
6#define QUICHE_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_
7
8#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h"
9
10namespace quic {
11
12namespace test {
13
14// This packet writer allows delaying writing the next packet after
15// SetDelay(num_packets_to_wait)
16// is called and buffer this packet and write it after it writes next
17// |num_packets_to_wait| packets. It doesn't support delaying a packet while
18// there is already a packet delayed.
19class PacketReorderingWriter : public QuicPacketWriterWrapper {
20 public:
21 PacketReorderingWriter();
22
23 ~PacketReorderingWriter() override;
24
25 WriteResult WritePacket(const char* buffer,
26 size_t buf_len,
27 const QuicIpAddress& self_address,
28 const QuicSocketAddress& peer_address,
29 PerPacketOptions* options) override;
30
31 void SetDelay(size_t num_packets_to_wait);
32
33 private:
34 bool delay_next_ = false;
35 size_t num_packets_to_wait_ = 0;
vasilvvc48c8712019-03-11 13:38:16 -070036 std::string delayed_data_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050037 QuicIpAddress delayed_self_address_;
38 QuicSocketAddress delayed_peer_address_;
39 std::unique_ptr<PerPacketOptions> delayed_options_;
40};
41
42} // namespace test
43} // namespace quic
44
45#endif // QUICHE_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_