Index: net/tools/quic/test_tools/packet_reordering_writer.h |
diff --git a/net/tools/quic/test_tools/packet_reordering_writer.h b/net/tools/quic/test_tools/packet_reordering_writer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d09aeb84a3a21cf39952c6313372af34f18fc142 |
--- /dev/null |
+++ b/net/tools/quic/test_tools/packet_reordering_writer.h |
@@ -0,0 +1,45 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |
+#define NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |
+ |
+#include "net/tools/quic/quic_packet_writer_wrapper.h" |
+ |
+namespace net { |
+ |
+namespace test { |
+ |
+// This packet writer allows delaying writing the next packet after |
+// SetDelay(num_packets_to_wait) |
+// is called and buffer this packet and write it after it writes next |
+// |num_packets_to_wait| packets. It doesn't support delaying a packet while |
+// there is already a packet delayed. |
+class PacketReorderingWriter : public QuicPacketWriterWrapper { |
+ public: |
+ PacketReorderingWriter(); |
+ |
+ ~PacketReorderingWriter() override; |
+ |
+ WriteResult WritePacket(const char* buffer, |
+ size_t buf_len, |
+ const IPAddress& self_address, |
+ const IPEndPoint& peer_address, |
+ PerPacketOptions* options) override; |
+ |
+ void SetDelay(size_t num_packets_to_wait); |
+ |
+ private: |
+ bool delay_next_ = false; |
+ size_t num_packets_to_wait_ = 0; |
+ std::string delayed_data_; |
+ IPAddress delayed_self_address_; |
+ IPEndPoint delayed_peer_address_; |
+ std::unique_ptr<PerPacketOptions> delayed_options_; |
+}; |
+ |
+} // namespace test |
+} // namespace net |
+ |
+#endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |