| 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_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ | 5 #ifndef NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ |
| 6 #define NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ | 6 #define NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "net/quic/core/quic_packet_writer.h" | 13 #include "net/quic/core/quic_packet_writer.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // Wraps a writer object to allow dynamically extending functionality. Use | 17 // Wraps a writer object to allow dynamically extending functionality. Use |
| 18 // cases: replace writer while dispatcher and connections hold on to the | 18 // cases: replace writer while dispatcher and connections hold on to the |
| 19 // wrapper; mix in monitoring; mix in mocks in unit tests. | 19 // wrapper; mix in monitoring; mix in mocks in unit tests. |
| 20 class QuicPacketWriterWrapper : public QuicPacketWriter { | 20 class QuicPacketWriterWrapper : public QuicPacketWriter { |
| 21 public: | 21 public: |
| 22 QuicPacketWriterWrapper(); | 22 QuicPacketWriterWrapper(); |
| 23 explicit QuicPacketWriterWrapper(QuicPacketWriter* writer); | |
| 24 ~QuicPacketWriterWrapper() override; | 23 ~QuicPacketWriterWrapper() override; |
| 25 | 24 |
| 26 // Default implementation of the QuicPacketWriter interface. Passes everything | 25 // Default implementation of the QuicPacketWriter interface. Passes everything |
| 27 // to |writer_|. | 26 // to |writer_|. |
| 28 WriteResult WritePacket(const char* buffer, | 27 WriteResult WritePacket(const char* buffer, |
| 29 size_t buf_len, | 28 size_t buf_len, |
| 30 const IPAddress& self_address, | 29 const IPAddress& self_address, |
| 31 const IPEndPoint& peer_address, | 30 const IPEndPoint& peer_address, |
| 32 PerPacketOptions* options) override; | 31 PerPacketOptions* options) override; |
| 33 bool IsWriteBlockedDataBuffered() const override; | 32 bool IsWriteBlockedDataBuffered() const override; |
| 34 bool IsWriteBlocked() const override; | 33 bool IsWriteBlocked() const override; |
| 35 void SetWritable() override; | 34 void SetWritable() override; |
| 36 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override; | 35 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override; |
| 37 | 36 |
| 38 // Takes ownership of |writer|. | 37 // Takes ownership of |writer|. |
| 39 void set_writer(QuicPacketWriter* writer); | 38 void set_writer(QuicPacketWriter* writer); |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 std::unique_ptr<QuicPacketWriter> writer_; | 41 std::unique_ptr<QuicPacketWriter> writer_; |
| 43 | 42 |
| 44 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper); | 43 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper); |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 } // namespace net | 46 } // namespace net |
| 48 | 47 |
| 49 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ | 48 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ |
| OLD | NEW |