blob: df30f248f40a253ced0ed161caa79d0a2f382963 [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_CORE_QUIC_DEFAULT_PACKET_WRITER_H_
6#define QUICHE_QUIC_CORE_QUIC_DEFAULT_PACKET_WRITER_H_
7
8#include <cstddef>
9
QUICHE team5be974e2020-12-29 18:35:24 -050010#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 teama6ef0a62019-03-07 20:34:33 -050013
14namespace quic {
15
16struct WriteResult;
17
18// Default packet writer which wraps QuicSocketUtils WritePacket.
19class 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;
wub50d4c712020-05-19 15:48:28 -070038 QuicPacketBuffer GetNextWriteLocation(
39 const QuicIpAddress& self_address,
40 const QuicSocketAddress& peer_address) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -050041 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_