Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / tools / quic / quic_packet_writer_wrapper.h
blob1ab474a145a5baf8ce6d58889df653a79704bad6
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"
11 namespace net {
13 namespace tools {
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; mix in mocks in unit tests.
18 class QuicPacketWriterWrapper : public QuicPacketWriter {
19 public:
20 QuicPacketWriterWrapper();
21 explicit QuicPacketWriterWrapper(QuicPacketWriter* writer);
22 ~QuicPacketWriterWrapper() override;
24 // Default implementation of the QuicPacketWriter interface. Passes everything
25 // to |writer_|.
26 WriteResult WritePacket(const char* buffer,
27 size_t buf_len,
28 const IPAddressNumber& self_address,
29 const IPEndPoint& peer_address) override;
30 bool IsWriteBlockedDataBuffered() const override;
31 bool IsWriteBlocked() const override;
32 void SetWritable() override;
33 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override;
35 // Takes ownership of |writer|.
36 void set_writer(QuicPacketWriter* writer);
38 private:
39 scoped_ptr<QuicPacketWriter> writer_;
41 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper);
44 } // namespace tools
45 } // namespace net
47 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_