OLD | NEW |
(Empty) | |
| 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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |
| 6 #define NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |
| 7 |
| 8 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 namespace 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. |
| 19 class 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 IPAddress& self_address, |
| 28 const IPEndPoint& 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; |
| 36 std::string delayed_data_; |
| 37 IPAddress delayed_self_address_; |
| 38 IPEndPoint delayed_peer_address_; |
| 39 std::unique_ptr<PerPacketOptions> delayed_options_; |
| 40 }; |
| 41 |
| 42 } // namespace test |
| 43 } // namespace net |
| 44 |
| 45 #endif // NET_TOOLS_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ |
OLD | NEW |