OLD | NEW |
---|---|
1 // Copyright 2013 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_DEFAULT_PACKET_WRITER_H_ | 5 #ifndef NET_QUIC_QUIC_CONNECTION_PACKET_WRITER_WRAPPER_H_ |
6 #define NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_ | 6 #define NET_QUIC_QUIC_CONNECTION_PACKET_WRITER_WRAPPER_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/datagram_client_socket.h" | 14 #include "net/quic/quic_types.h" |
15 #include "net/udp/udp_server_socket.h" | |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 struct WriteResult; | 19 class QuicBlockedWriterInterface; |
20 class QuicServerPacketWriter; | |
19 | 21 |
20 // Chrome specific packet writer which uses a DatagramClientSocket for writing | 22 // A wrapper packet writer that notifies a particular connection after its |
21 // data. | 23 // writes to the shared server packet writer finish. |
22 class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter { | 24 class QuicConnectionPacketWriterWrapper : public QuicPacketWriter { |
Ryan Hamilton
2014/06/19 19:21:29
It's worth thinking about how we could potentially
dmz
2014/06/19 20:06:28
Done.
| |
23 public: | 25 public: |
24 QuicDefaultPacketWriter(); | 26 QuicConnectionPacketWriterWrapper(QuicServerPacketWriter* writer, |
25 explicit QuicDefaultPacketWriter(DatagramClientSocket* socket); | 27 QuicConnection* connection); |
26 virtual ~QuicDefaultPacketWriter(); | 28 virtual ~QuicConnectionPacketWriterWrapper(); |
27 | 29 |
28 // QuicPacketWriter | 30 // QuicPacketWriter |
29 virtual WriteResult WritePacket(const char* buffer, | 31 virtual WriteResult WritePacket(const char* buffer, |
30 size_t buf_len, | 32 size_t buf_len, |
31 const IPAddressNumber& self_address, | 33 const IPAddressNumber& self_address, |
32 const IPEndPoint& peer_address) OVERRIDE; | 34 const IPEndPoint& peer_address) OVERRIDE; |
33 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 35 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
34 virtual bool IsWriteBlocked() const OVERRIDE; | 36 virtual bool IsWriteBlocked() const OVERRIDE; |
35 virtual void SetWritable() OVERRIDE; | 37 virtual void SetWritable() OVERRIDE; |
36 | 38 |
37 void OnWriteComplete(int rv); | 39 private: |
38 void SetConnection(QuicConnection* connection) { | 40 void OnWriteComplete(WriteResult wr); |
39 connection_ = connection; | |
40 } | |
41 | 41 |
42 protected: | 42 base::WeakPtrFactory<QuicConnectionPacketWriterWrapper> weak_factory_; |
43 void set_write_blocked(bool is_blocked) { | 43 QuicServerPacketWriter* writer_; |
Ryan Hamilton
2014/06/19 19:21:29
Please add a comment that this is not owned.
dmz
2014/06/19 20:06:28
Done.
| |
44 write_blocked_ = is_blocked; | 44 QuicConnection* connection_; |
45 } | |
46 | 45 |
47 private: | 46 DISALLOW_COPY_AND_ASSIGN(QuicConnectionPacketWriterWrapper); |
48 base::WeakPtrFactory<QuicDefaultPacketWriter> weak_factory_; | |
49 DatagramClientSocket* socket_; | |
50 QuicConnection* connection_; | |
51 bool write_blocked_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(QuicDefaultPacketWriter); | |
54 }; | 47 }; |
55 | 48 |
56 } // namespace net | 49 } // namespace net |
57 | 50 |
58 #endif // NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_ | 51 #endif // NET_QUIC_QUIC_CONNECTION_PACKET_WRITER_WRAPPER_H_ |
OLD | NEW |