QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 QUICHE_QUIC_CORE_QUIC_DEFAULT_PACKET_WRITER_H_ |
| 6 | #define QUICHE_QUIC_CORE_QUIC_DEFAULT_PACKET_WRITER_H_ |
| 7 | |
| 8 | #include <cstddef> |
| 9 | |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 10 | #include "quic/core/quic_packet_writer.h" |
| 11 | #include "quic/platform/api/quic_export.h" |
| 12 | #include "quic/platform/api/quic_socket_address.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | |
| 14 | namespace quic { |
| 15 | |
| 16 | struct WriteResult; |
| 17 | |
| 18 | // Default packet writer which wraps QuicSocketUtils WritePacket. |
| 19 | class QUIC_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter { |
| 20 | public: |
| 21 | explicit QuicDefaultPacketWriter(int fd); |
| 22 | QuicDefaultPacketWriter(const QuicDefaultPacketWriter&) = delete; |
| 23 | QuicDefaultPacketWriter& operator=(const QuicDefaultPacketWriter&) = delete; |
| 24 | ~QuicDefaultPacketWriter() override; |
| 25 | |
| 26 | // QuicPacketWriter |
| 27 | WriteResult WritePacket(const char* buffer, |
| 28 | size_t buf_len, |
| 29 | const QuicIpAddress& self_address, |
| 30 | const QuicSocketAddress& peer_address, |
| 31 | PerPacketOptions* options) override; |
| 32 | bool IsWriteBlocked() const override; |
| 33 | void SetWritable() override; |
| 34 | QuicByteCount GetMaxPacketSize( |
| 35 | const QuicSocketAddress& peer_address) const override; |
| 36 | bool SupportsReleaseTime() const override; |
| 37 | bool IsBatchMode() const override; |
wub | 50d4c71 | 2020-05-19 15:48:28 -0700 | [diff] [blame] | 38 | QuicPacketBuffer GetNextWriteLocation( |
| 39 | const QuicIpAddress& self_address, |
| 40 | const QuicSocketAddress& peer_address) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 41 | WriteResult Flush() override; |
| 42 | |
| 43 | void set_fd(int fd) { fd_ = fd; } |
| 44 | |
| 45 | protected: |
| 46 | void set_write_blocked(bool is_blocked); |
| 47 | int fd() { return fd_; } |
| 48 | |
| 49 | private: |
| 50 | int fd_; |
| 51 | bool write_blocked_; |
| 52 | }; |
| 53 | |
| 54 | } // namespace quic |
| 55 | |
| 56 | #endif // QUICHE_QUIC_CORE_QUIC_DEFAULT_PACKET_WRITER_H_ |