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. 4 5 #ifndef NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_ 6 #define NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/weak_ptr.h" 10 #include "net/base/ip_endpoint.h" 11 #include "net/quic/quic_connection.h" 12 #include "net/quic/quic_packet_writer.h" 13 #include "net/quic/quic_protocol.h" 14 #include "net/udp/datagram_client_socket.h" 15 16 namespace net { 17 18 class QuicBlockedWriterInterface; 19 20 // Chrome specific packet writer which uses a DatagramClientSocket for writing 21 // data. 22 class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter { 23 public: 24 QuicDefaultPacketWriter(); 25 explicit QuicDefaultPacketWriter(DatagramClientSocket* socket); 26 virtual ~QuicDefaultPacketWriter(); 27 28 // QuicPacketWriter 29 virtual WriteResult WritePacket( 30 const char* buffer, size_t buf_len, 31 const net::IPAddressNumber& self_address, 32 const net::IPEndPoint& peer_address, 33 QuicBlockedWriterInterface* blocked_writer) OVERRIDE; 34 35 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; 36 37 void OnWriteComplete(int rv); 38 void SetConnection(QuicConnection* connection) { 39 connection_ = connection; 40 } 41 42 private: 43 base::WeakPtrFactory<QuicDefaultPacketWriter> weak_factory_; 44 DatagramClientSocket* socket_; 45 QuicConnection* connection_; 46 }; 47 48 } // namespace net 49 50 #endif // NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_ 51