Chromium Code Reviews| Index: net/quic/quic_server_packet_writer.h |
| diff --git a/net/quic/quic_server_packet_writer.h b/net/quic/quic_server_packet_writer.h |
| index 63829935521019e5712e27410f70bbc38485ff40..6e58d74ad188a407335b8d183340b6ce6e56d0b6 100644 |
| --- a/net/quic/quic_server_packet_writer.h |
| +++ b/net/quic/quic_server_packet_writer.h |
| @@ -11,38 +11,56 @@ |
| #include "net/quic/quic_connection.h" |
| #include "net/quic/quic_packet_writer.h" |
| #include "net/quic/quic_protocol.h" |
| -#include "net/udp/udp_server_socket.h" |
| namespace net { |
| +class QuicBlockedWriterInterface; |
| +class UDPServerSocket; |
| struct WriteResult; |
| // Chrome specific packet writer which uses a UDPServerSocket for writing |
| // data. |
| class QuicServerPacketWriter : public QuicPacketWriter { |
| public: |
| - QuicServerPacketWriter(); |
| - explicit QuicServerPacketWriter(UDPServerSocket* socket); |
| + typedef base::Callback<void(WriteResult)> WriteCallback; |
| + |
| + QuicServerPacketWriter(UDPServerSocket* socket, |
| + QuicBlockedWriterInterface* blocked_writer); |
| virtual ~QuicServerPacketWriter(); |
| + // Use this method to write packets rather than WritePacket: this class |
|
wtc
2014/06/23 23:12:16
Should "this class" be changed to "this method"?
dmziegler
2014/06/24 00:08:53
No, actually, QuicServerPacketWriter can't be used
|
| + // requires a callback to exist, which will be called once the write |
| + // completes. |
| + virtual WriteResult WritePacketWithCallback( |
| + const char* buffer, |
| + size_t buf_len, |
| + const IPAddressNumber& self_address, |
| + const IPEndPoint& peer_address, |
| + WriteCallback callback); |
| + |
| // QuicPacketWriter |
| virtual WriteResult WritePacket(const char* buffer, |
| size_t buf_len, |
| - const net::IPAddressNumber& self_address, |
| - const net::IPEndPoint& peer_address) OVERRIDE; |
| + const IPAddressNumber& self_address, |
| + const IPEndPoint& peer_address) OVERRIDE; |
| virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
| virtual bool IsWriteBlocked() const OVERRIDE; |
| virtual void SetWritable() OVERRIDE; |
| void OnWriteComplete(int rv); |
| - void SetConnection(QuicConnection* connection) { |
| - connection_ = connection; |
| - } |
| + |
| private: |
| base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; |
| UDPServerSocket* socket_; |
| - QuicConnection* connection_; |
| + |
| + // To be notified after every successful asynchronous write. |
| + QuicBlockedWriterInterface* blocked_writer_; |
| + |
| + // To call once the write completes. |
| + WriteCallback callback_; |
| + |
| + // Whether a write is currently in flight. |
| bool write_blocked_; |
| DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); |