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

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

Issue 340433002: Port QuicServer to Chrome network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Additional comments 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_QUIC_QUIC_SERVER_PACKET_WRITER_H_ 5 #ifndef NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_
6 #define NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ 6 #define NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
11 #include "net/quic/quic_connection.h" 11 #include "net/quic/quic_connection.h"
12 #include "net/quic/quic_packet_writer.h" 12 #include "net/quic/quic_packet_writer.h"
13 #include "net/quic/quic_protocol.h" 13 #include "net/quic/quic_protocol.h"
14 #include "net/quic/quic_types.h"
14 #include "net/udp/udp_server_socket.h" 15 #include "net/udp/udp_server_socket.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 struct WriteResult; 19 class QuicBlockedWriterInterface;
19 20
20 // Chrome specific packet writer which uses a UDPServerSocket for writing 21 // Chrome specific packet writer which uses a UDPServerSocket for writing
21 // data. 22 // data.
22 class QuicServerPacketWriter : public QuicPacketWriter { 23 class QuicServerPacketWriter : public QuicPacketWriter {
23 public: 24 public:
24 QuicServerPacketWriter(); 25 QuicServerPacketWriter(QuicBlockedWriterInterface* blocked_writer,
25 explicit QuicServerPacketWriter(UDPServerSocket* socket); 26 UDPServerSocket* socket);
26 virtual ~QuicServerPacketWriter(); 27 virtual ~QuicServerPacketWriter();
27 28
28 // QuicPacketWriter 29 // QuicPacketWriter
29 virtual WriteResult WritePacket(const char* buffer, 30 virtual WriteResult WritePacket(const char* buffer,
30 size_t buf_len, 31 size_t buf_len,
31 const net::IPAddressNumber& self_address, 32 const IPAddressNumber& self_address,
32 const net::IPEndPoint& peer_address) OVERRIDE; 33 const IPEndPoint& peer_address) OVERRIDE;
33 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; 34 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE;
34 virtual bool IsWriteBlocked() const OVERRIDE; 35 virtual bool IsWriteBlocked() const OVERRIDE;
35 virtual void SetWritable() OVERRIDE; 36 virtual void SetWritable() OVERRIDE;
36 37
37 void OnWriteComplete(int rv); 38 void OnWriteComplete(int rv);
38 void SetConnection(QuicConnection* connection) { 39 void SetWriteCallback(base::Callback<void(WriteResult wr)> callback) {
39 connection_ = connection; 40 callback_ = callback;
40 } 41 }
41 42
42 private: 43 private:
43 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_; 44 base::WeakPtrFactory<QuicServerPacketWriter> weak_factory_;
44 UDPServerSocket* socket_; 45 UDPServerSocket* socket_;
45 QuicConnection* connection_; 46
47 // To be notified after every successful asynchronous write.
48 QuicBlockedWriterInterface* blocked_writer_;
49 base::Callback<void(WriteResult wr)> callback_;
46 bool write_blocked_; 50 bool write_blocked_;
47 51
48 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter); 52 DISALLOW_COPY_AND_ASSIGN(QuicServerPacketWriter);
49 }; 53 };
50 54
51 } // namespace net 55 } // namespace net
52 56
53 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_ 57 #endif // NET_QUIC_QUIC_SERVER_PACKET_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698