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

Side by Side Diff: net/quic/quic_per_connection_packet_writer.h

Issue 475113005: Refactoring: Create per-connection packet writers in QuicDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add new files to net/BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_http_stream_test.cc ('k') | net/quic/quic_per_connection_packet_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_ 5 #ifndef NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_
6 #define NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_ 6 #define NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_
7 7
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
10 #include "net/base/ip_endpoint.h"
11 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
12 #include "net/quic/quic_packet_writer.h" 10 #include "net/quic/quic_packet_writer.h"
13 #include "net/quic/quic_protocol.h"
14 #include "net/quic/quic_types.h"
15 11
16 namespace net { 12 namespace net {
17 13
18 class QuicServerPacketWriter; 14 class QuicServerPacketWriter;
19 15
20 // A connection-specific packet writer that notifies its connection when its 16 // A connection-specific packet writer that notifies its connection when its
21 // writes to the shared QuicServerPacketWriter complete. 17 // writes to the shared QuicServerPacketWriter complete.
22 // This class is necessary because multiple connections can share the same 18 // This class is necessary because multiple connections can share the same
23 // QuicServerPacketWriter, so it has no way to know which connection to notify. 19 // QuicServerPacketWriter, so it has no way to know which connection to notify.
24 // TODO(dmz) Try to merge with Chrome's default packet writer
25 class QuicPerConnectionPacketWriter : public QuicPacketWriter { 20 class QuicPerConnectionPacketWriter : public QuicPacketWriter {
26 public: 21 public:
27 QuicPerConnectionPacketWriter(QuicServerPacketWriter* writer); 22 // Does not take ownership of |shared_writer| or |connection|.
23 QuicPerConnectionPacketWriter(QuicServerPacketWriter* shared_writer,
24 QuicConnection* connection);
28 virtual ~QuicPerConnectionPacketWriter(); 25 virtual ~QuicPerConnectionPacketWriter();
29 26
30 // Set the connection to notify after writes complete. 27 QuicPacketWriter* shared_writer() const;
31 void set_connection(QuicConnection* connection) { connection_ = connection; } 28 QuicConnection* connection() const { return connection_; }
32 29
33 // QuicPacketWriter 30 // Default implementation of the QuicPacketWriter interface: Passes everything
31 // to |shared_writer_|.
34 virtual WriteResult WritePacket(const char* buffer, 32 virtual WriteResult WritePacket(const char* buffer,
35 size_t buf_len, 33 size_t buf_len,
36 const IPAddressNumber& self_address, 34 const IPAddressNumber& self_address,
37 const IPEndPoint& peer_address) OVERRIDE; 35 const IPEndPoint& peer_address) OVERRIDE;
38 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; 36 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE;
39 virtual bool IsWriteBlocked() const OVERRIDE; 37 virtual bool IsWriteBlocked() const OVERRIDE;
40 virtual void SetWritable() OVERRIDE; 38 virtual void SetWritable() OVERRIDE;
41 39
42 private: 40 private:
43 void OnWriteComplete(WriteResult result); 41 void OnWriteComplete(WriteResult result);
44 42
45 base::WeakPtrFactory<QuicPerConnectionPacketWriter> weak_factory_; 43 base::WeakPtrFactory<QuicPerConnectionPacketWriter> weak_factory_;
46 QuicServerPacketWriter* writer_; // Not owned. 44 QuicServerPacketWriter* shared_writer_; // Not owned.
47 QuicConnection* connection_; 45 QuicConnection* connection_; // Not owned.
48 46
49 DISALLOW_COPY_AND_ASSIGN(QuicPerConnectionPacketWriter); 47 DISALLOW_COPY_AND_ASSIGN(QuicPerConnectionPacketWriter);
50 }; 48 };
51 49
52 } // namespace net 50 } // namespace net
53 51
54 #endif // NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_ 52 #endif // NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_http_stream_test.cc ('k') | net/quic/quic_per_connection_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698