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.
5 #ifndef NET_QUIC_QUIC_PACKET_WRITER_H_
6 #define NET_QUIC_QUIC_PACKET_WRITER_H_
8 #include "net/base/ip_endpoint.h"
9 #include "net/quic/quic_protocol.h"
13 class QuicBlockedWriterInterface
;
16 // An interface between writers and the entity managing the
17 // socket (in our case the QuicDispatcher). This allows the Dispatcher to
18 // control writes, and manage any writers who end up write blocked.
19 class NET_EXPORT_PRIVATE QuicPacketWriter
{
21 virtual ~QuicPacketWriter() {}
23 // Sends the packet out to the peer. If the write succeeded, the result's
24 // status is WRITE_STATUS_OK and bytes_written is populated. If the write
25 // failed, the result's status is WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR
26 // and error_code is populated.
27 virtual WriteResult
WritePacket(
28 const char* buffer
, size_t buf_len
,
29 const IPAddressNumber
& self_address
,
30 const IPEndPoint
& peer_address
,
31 QuicBlockedWriterInterface
* blocked_writer
) = 0;
33 // Returns true if the writer buffers and subsequently rewrites data
34 // when an attempt to write results in the underlying socket becoming
36 virtual bool IsWriteBlockedDataBuffered() const = 0;
38 // Returns true if the network socket is not writable.
39 virtual bool IsWriteBlocked() const = 0;
41 // Records that the socket has become writable, for example when an EPOLLOUT
42 // is received or an asynchronous write completes.
43 virtual void SetWritable() = 0;
48 #endif // NET_QUIC_QUIC_PACKET_WRITER_H_