Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: net/tools/quic/quic_packet_writer_wrapper.h

Issue 340433002: Port QuicServer to Chrome network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments and fix blocked writers using callbacks Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/quic/quic_packet_writer.h" 9 #include "net/quic/quic_packet_writer.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 namespace tools { 13 namespace tools {
14 14
15 // Wraps a writer object to allow dynamically extending functionality. Use 15 // Wraps a writer object to allow dynamically extending functionality. Use
16 // cases: replace writer while dispatcher and connections hold on to the 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. 17 // wrapper; mix in monitoring in internal server; mix in mocks in unit tests.
18 class QuicPacketWriterWrapper : public net::QuicPacketWriter { 18 class QuicPacketWriterWrapper : public net::QuicPacketWriter {
19 public: 19 public:
20 QuicPacketWriterWrapper(); 20 QuicPacketWriterWrapper();
21 explicit QuicPacketWriterWrapper(QuicPacketWriter* writer); 21 explicit QuicPacketWriterWrapper(QuicPacketWriter* writer);
22 virtual ~QuicPacketWriterWrapper(); 22 virtual ~QuicPacketWriterWrapper();
23 23
24 // Default implementation of the QuicPacketWriter interface. Passes everything 24 // Default implementation of the QuicPacketWriter interface. Passes everything
25 // to |writer_|. 25 // to |writer_|.
26 virtual WriteResult WritePacket( 26 virtual WriteResult WritePacket(
27 const char* buffer, 27 const char* buffer,
28 size_t buf_len, 28 size_t buf_len,
29 const IPAddressNumber& self_address, 29 const IPAddressNumber& self_address,
30 const IPEndPoint& peer_address) OVERRIDE; 30 const IPEndPoint& peer_address,
31 base::Callback<void(WriteResult wr)> callback) OVERRIDE;
31 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; 32 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE;
32 virtual bool IsWriteBlocked() const OVERRIDE; 33 virtual bool IsWriteBlocked() const OVERRIDE;
33 virtual void SetWritable() OVERRIDE; 34 virtual void SetWritable() OVERRIDE;
34 35
35 // Takes ownership of |writer|. 36 // Takes ownership of |writer|.
36 void set_writer(QuicPacketWriter* writer); 37 void set_writer(QuicPacketWriter* writer);
37 38
38 // Releases ownership of |writer_|. 39 // Releases ownership of |writer_|.
39 QuicPacketWriter* release_writer(); 40 QuicPacketWriter* release_writer();
40 41
41 private: 42 private:
42 scoped_ptr<QuicPacketWriter> writer_; 43 scoped_ptr<QuicPacketWriter> writer_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper); 45 DISALLOW_COPY_AND_ASSIGN(QuicPacketWriterWrapper);
45 }; 46 };
46 47
47 } // namespace tools 48 } // namespace tools
48 } // namespace net 49 } // namespace net
49 50
50 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_ 51 #endif // NET_TOOLS_QUIC_QUIC_PACKET_WRITER_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698