OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ | 5 #ifndef NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ |
6 #define NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ | 6 #define NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 #include "net/quic/quic_connection.h" | 11 #include "net/quic/quic_connection.h" |
12 #include "net/quic/quic_packet_writer.h" | 12 #include "net/quic/quic_packet_writer.h" |
13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
14 #include "net/quic/quic_types.h" | |
14 #include "net/udp/udp_server_socket.h" | 15 #include "net/udp/udp_server_socket.h" |
wtc
2014/06/20 21:40:50
A forward declaration of class UDPServerSocket may
dmziegler
2014/06/23 18:31:25
Done.
| |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 struct WriteResult; | 19 class QuicBlockedWriterInterface; |
19 | 20 |
20 // Chrome specific packet writer which uses a UDPServerSocket for writing | 21 // Chrome specific packet writer which uses a UDPServerSocket for writing |
21 // data. | 22 // data. |
22 class QuicServerPacketWriter : public QuicPacketWriter { | 23 class QuicServerPacketWriter : public QuicPacketWriter { |
23 public: | 24 public: |
24 QuicServerPacketWriter(); | 25 typedef base::Callback<void(WriteResult)> WriteCallback; |
25 explicit QuicServerPacketWriter(UDPServerSocket* socket); | 26 |
27 QuicServerPacketWriter(QuicBlockedWriterInterface* blocked_writer, | |
28 UDPServerSocket* socket); | |
wtc
2014/06/20 21:40:50
Nit: I would reorder these two parameters because
dmziegler
2014/06/23 18:31:24
Done.
| |
26 virtual ~QuicServerPacketWriter(); | 29 virtual ~QuicServerPacketWriter(); |
27 | 30 |
31 virtual WriteResult WritePacketWithCallback( | |
wtc
2014/06/20 21:40:50
Document this method.
dmziegler
2014/06/23 18:31:24
Done.
| |
32 const char* buffer, | |
33 size_t buf_len, | |
34 const IPAddressNumber& self_address, | |
35 const IPEndPoint& peer_address, | |
36 WriteCallback callback); | |
37 | |
28 // QuicPacketWriter | 38 // QuicPacketWriter |
29 virtual WriteResult WritePacket(const char* buffer, | 39 virtual WriteResult WritePacket(const char* buffer, |
30 size_t buf_len, | 40 size_t buf_len, |
31 const net::IPAddressNumber& self_address, | 41 const IPAddressNumber& self_address, |
32 const net::IPEndPoint& peer_address) OVERRIDE; | 42 const IPEndPoint& peer_address) OVERRIDE; |
33 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 43 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
34 virtual bool IsWriteBlocked() const OVERRIDE; | 44 virtual bool IsWriteBlocked() const OVERRIDE; |
35 virtual void SetWritable() OVERRIDE; | 45 virtual void SetWritable() OVERRIDE; |
36 | 46 |
37 void OnWriteComplete(int rv); | 47 void OnWriteComplete(int rv); |
38 void SetConnection(QuicConnection* connection) { | 48 |
39 connection_ = connection; | |
40 } | |
41 | 49 |
42 private: | 50 private: |
43 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; | 51 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; |
44 UDPServerSocket* socket_; | 52 UDPServerSocket* socket_; |
45 QuicConnection* connection_; | 53 |
54 // To be notified after every successful asynchronous write. | |
55 QuicBlockedWriterInterface* blocked_writer_; | |
56 base::Callback<void(WriteResult wr)> callback_; | |
wtc
2014/06/20 21:40:50
Change "wr" to "result". But we should be able to
dmziegler
2014/06/23 18:31:24
Done.
| |
46 bool write_blocked_; | 57 bool write_blocked_; |
47 | 58 |
48 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); | 59 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); |
49 }; | 60 }; |
50 | 61 |
51 } // namespace net | 62 } // namespace net |
52 | 63 |
53 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ | 64 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ |
OLD | NEW |