Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / quic / quic_packet_writer.h
blobb8ee2933bd2178c191871280cfe2c7489c4672b6
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"
10 namespace net {
12 struct WriteResult;
14 // An interface between writers and the entity managing the
15 // socket (in our case the QuicDispatcher). This allows the Dispatcher to
16 // control writes, and manage any writers who end up write blocked.
17 class NET_EXPORT_PRIVATE QuicPacketWriter {
18 public:
19 virtual ~QuicPacketWriter() {}
21 // Sends the packet out to the peer. If the write succeeded, the result's
22 // status is WRITE_STATUS_OK and bytes_written is populated. If the write
23 // failed, the result's status is WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR
24 // and error_code is populated.
25 virtual WriteResult WritePacket(
26 const char* buffer, size_t buf_len,
27 const IPAddressNumber& self_address,
28 const IPEndPoint& peer_address) = 0;
30 // Returns true if the writer buffers and subsequently rewrites data
31 // when an attempt to write results in the underlying socket becoming
32 // write blocked.
33 virtual bool IsWriteBlockedDataBuffered() const = 0;
35 // Returns true if the network socket is not writable.
36 virtual bool IsWriteBlocked() const = 0;
38 // Records that the socket has become writable, for example when an EPOLLOUT
39 // is received or an asynchronous write completes.
40 virtual void SetWritable() = 0;
43 } // namespace net
45 #endif // NET_QUIC_QUIC_PACKET_WRITER_H_