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

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

Issue 2180003004: Remove inability to call QuicSimpleServerPacketWriter::WritePacket directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | net/tools/quic/quic_simple_server_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_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_ 5 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_
6 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_ 6 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 15 matching lines...) Expand all
26 // Chrome specific packet writer which uses a UDPServerSocket for writing 26 // Chrome specific packet writer which uses a UDPServerSocket for writing
27 // data. 27 // data.
28 class QuicSimpleServerPacketWriter : public QuicPacketWriter { 28 class QuicSimpleServerPacketWriter : public QuicPacketWriter {
29 public: 29 public:
30 typedef base::Callback<void(WriteResult)> WriteCallback; 30 typedef base::Callback<void(WriteResult)> WriteCallback;
31 31
32 QuicSimpleServerPacketWriter(UDPServerSocket* socket, 32 QuicSimpleServerPacketWriter(UDPServerSocket* socket,
33 QuicBlockedWriterInterface* blocked_writer); 33 QuicBlockedWriterInterface* blocked_writer);
34 ~QuicSimpleServerPacketWriter() override; 34 ~QuicSimpleServerPacketWriter() override;
35 35
36 // Use this method to write packets rather than WritePacket: 36 // Wraps WritePacket, and ensures that |callback| is run on successful write.
37 // QuicSimpleServerPacketWriter requires a callback to exist for every 37 WriteResult WritePacketWithCallback(const char* buffer,
38 // write, which will be called once the write completes. 38 size_t buf_len,
39 virtual WriteResult WritePacketWithCallback(const char* buffer, 39 const IPAddress& self_address,
40 size_t buf_len, 40 const IPEndPoint& peer_address,
41 const IPAddress& self_address, 41 PerPacketOptions* options,
42 const IPEndPoint& peer_address, 42 WriteCallback callback);
43 PerPacketOptions* options, 43
44 WriteCallback callback); 44 WriteResult WritePacket(const char* buffer,
45 size_t buf_len,
46 const IPAddress& self_address,
47 const IPEndPoint& peer_address,
48 PerPacketOptions* options) override;
45 49
46 void OnWriteComplete(int rv); 50 void OnWriteComplete(int rv);
47 51
48 // QuicPacketWriter implementation: 52 // QuicPacketWriter implementation:
49 bool IsWriteBlockedDataBuffered() const override; 53 bool IsWriteBlockedDataBuffered() const override;
50 bool IsWriteBlocked() const override; 54 bool IsWriteBlocked() const override;
51 void SetWritable() override; 55 void SetWritable() override;
52 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override; 56 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override;
53 57
54 protected:
55 // Do not call WritePacket on its own -- use WritePacketWithCallback
56 WriteResult WritePacket(const char* buffer,
57 size_t buf_len,
58 const IPAddress& self_address,
59 const IPEndPoint& peer_address,
60 PerPacketOptions* options) override;
61
62 private: 58 private:
63 UDPServerSocket* socket_; 59 UDPServerSocket* socket_;
64 60
65 // To be notified after every successful asynchronous write. 61 // To be notified after every successful asynchronous write.
66 QuicBlockedWriterInterface* blocked_writer_; 62 QuicBlockedWriterInterface* blocked_writer_;
67 63
68 // To call once the write completes. 64 // To call once the write completes.
69 WriteCallback callback_; 65 WriteCallback callback_;
70 66
71 // Whether a write is currently in flight. 67 // Whether a write is currently in flight.
72 bool write_blocked_; 68 bool write_blocked_;
73 69
74 base::WeakPtrFactory<QuicSimpleServerPacketWriter> weak_factory_; 70 base::WeakPtrFactory<QuicSimpleServerPacketWriter> weak_factory_;
75 71
76 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerPacketWriter); 72 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerPacketWriter);
77 }; 73 };
78 74
79 } // namespace net 75 } // namespace net
80 76
81 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_ 77 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_
OLDNEW
« no previous file with comments | « no previous file | net/tools/quic/quic_simple_server_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698