QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright 2017 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_BAD_PACKET_WRITER_H_ |
| 6 | #define QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_ |
| 7 | |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" |
| 9 | |
| 10 | namespace quic { |
| 11 | |
| 12 | namespace test { |
| 13 | // This packet writer allows causing packet write error with specified error |
| 14 | // code when writing a particular packet. |
| 15 | class BadPacketWriter : public QuicPacketWriterWrapper { |
| 16 | public: |
| 17 | BadPacketWriter(size_t packet_causing_write_error, int error_code); |
| 18 | |
| 19 | ~BadPacketWriter() override; |
| 20 | |
| 21 | WriteResult WritePacket(const char* buffer, |
| 22 | size_t buf_len, |
| 23 | const QuicIpAddress& self_address, |
| 24 | const QuicSocketAddress& peer_address, |
| 25 | PerPacketOptions* options) override; |
| 26 | |
| 27 | private: |
| 28 | size_t packet_causing_write_error_; |
| 29 | int error_code_; |
| 30 | }; |
| 31 | |
| 32 | } // namespace test |
| 33 | |
| 34 | } // namespace quic |
| 35 | |
| 36 | #endif // QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_ |