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
3 // found in the LICENSE file.
5 #ifndef NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_
6 #define NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "net/quic/quic_packet_writer.h"
15 // Wraps a writer object to allow dynamically extending functionality. Use
16 // cases: replace writer while dispatcher and connections hold on to the
17 // wrapper; mix in monitoring in internal server; mix in mocks in unit tests.
18 class QuicPacketWriterWrapper : public net::QuicPacketWriter {
20 QuicPacketWriterWrapper();
21 explicit QuicPacketWriterWrapper(QuicPacketWriter* writer);
22 virtual ~QuicPacketWriterWrapper();
24 // Default implementation of the QuicPacketWriter interface. Passes everything
26 virtual WriteResult WritePacket(
29 const IPAddressNumber& self_address,
30 const IPEndPoint& peer_address) OVERRIDE;
31 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE;
32 virtual bool IsWriteBlocked() const OVERRIDE;
33 virtual void SetWritable() OVERRIDE;
35 // Takes ownership of |writer|.
36 void set_writer(QuicPacketWriter* writer);
38 // Releases ownership of |writer_|.
39 QuicPacketWriter* release_writer();
42 scoped_ptr<QuicPacketWriter> writer_;
44 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper);
50 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_