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/udp/udp_server_socket.h" | 14 #include "net/udp/udp_server_socket.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 class QuicDispatcher; | |
wtc
2014/06/18 02:04:47
Delete the unused forward declaration.
dmziegler
2014/06/18 20:13:42
Done.
| |
18 struct WriteResult; | 19 struct WriteResult; |
wtc
2014/06/18 02:04:47
I think this forward declaration can be removed. I
dmziegler
2014/06/18 20:13:41
Done.
| |
19 | 20 |
21 class QuicServerPacketWriterVisitor { | |
22 public: | |
23 virtual ~QuicServerPacketWriterVisitor() {} | |
24 | |
25 virtual void OnCanWrite() {} | |
wtc
2014/06/18 02:04:47
Document this method.
This method should be abstr
dmziegler
2014/06/18 20:13:42
(This got deleted)
| |
26 }; | |
27 | |
20 // Chrome specific packet writer which uses a UDPServerSocket for writing | 28 // Chrome specific packet writer which uses a UDPServerSocket for writing |
21 // data. | 29 // data. |
22 class QuicServerPacketWriter : public QuicPacketWriter { | 30 class QuicServerPacketWriter : public QuicPacketWriter { |
23 public: | 31 public: |
24 QuicServerPacketWriter(); | 32 QuicServerPacketWriter(); |
25 explicit QuicServerPacketWriter(UDPServerSocket* socket); | 33 QuicServerPacketWriter(QuicServerPacketWriterVisitor* visitor, |
34 UDPServerSocket* socket); | |
26 virtual ~QuicServerPacketWriter(); | 35 virtual ~QuicServerPacketWriter(); |
27 | 36 |
28 // QuicPacketWriter | 37 // QuicPacketWriter |
29 virtual WriteResult WritePacket(const char* buffer, | 38 virtual WriteResult WritePacket(const char* buffer, |
30 size_t buf_len, | 39 size_t buf_len, |
31 const net::IPAddressNumber& self_address, | 40 const IPAddressNumber& self_address, |
32 const net::IPEndPoint& peer_address) OVERRIDE; | 41 const IPEndPoint& peer_address) OVERRIDE; |
33 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 42 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
34 virtual bool IsWriteBlocked() const OVERRIDE; | 43 virtual bool IsWriteBlocked() const OVERRIDE; |
35 virtual void SetWritable() OVERRIDE; | 44 virtual void SetWritable() OVERRIDE; |
36 | 45 |
37 void OnWriteComplete(int rv); | 46 void OnWriteComplete(int rv); |
38 void SetConnection(QuicConnection* connection) { | 47 void SetConnection(QuicConnection* connection) { |
39 connection_ = connection; | 48 connection_ = connection; |
40 } | 49 } |
41 | 50 |
42 private: | 51 private: |
43 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; | 52 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; |
44 UDPServerSocket* socket_; | 53 UDPServerSocket* socket_; |
54 QuicServerPacketWriterVisitor* visitor_; | |
wtc
2014/06/18 02:04:47
Nit: the order of these two members should match t
dmziegler
2014/06/18 20:13:41
No longer in the constructor.
| |
45 QuicConnection* connection_; | 55 QuicConnection* connection_; |
46 bool write_blocked_; | 56 bool write_blocked_; |
47 | 57 |
48 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); | 58 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); |
49 }; | 59 }; |
50 | 60 |
51 } // namespace net | 61 } // namespace net |
52 | 62 |
53 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ | 63 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ |
OLD | NEW |