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_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 22 matching lines...) Expand all Loading... |
33 ~QuicSimpleServerPacketWriter() override; | 33 ~QuicSimpleServerPacketWriter() override; |
34 | 34 |
35 // Use this method to write packets rather than WritePacket: | 35 // Use this method to write packets rather than WritePacket: |
36 // QuicSimpleServerPacketWriter requires a callback to exist for every | 36 // QuicSimpleServerPacketWriter requires a callback to exist for every |
37 // write, which will be called once the write completes. | 37 // write, which will be called once the write completes. |
38 virtual WriteResult WritePacketWithCallback( | 38 virtual WriteResult WritePacketWithCallback( |
39 const char* buffer, | 39 const char* buffer, |
40 size_t buf_len, | 40 size_t buf_len, |
41 const IPAddressNumber& self_address, | 41 const IPAddressNumber& self_address, |
42 const IPEndPoint& peer_address, | 42 const IPEndPoint& peer_address, |
| 43 PerPacketOptions* options, |
43 WriteCallback callback); | 44 WriteCallback callback); |
44 | 45 |
45 void OnWriteComplete(int rv); | 46 void OnWriteComplete(int rv); |
46 | 47 |
47 // QuicPacketWriter implementation: | 48 // QuicPacketWriter implementation: |
48 bool IsWriteBlockedDataBuffered() const override; | 49 bool IsWriteBlockedDataBuffered() const override; |
49 bool IsWriteBlocked() const override; | 50 bool IsWriteBlocked() const override; |
50 void SetWritable() override; | 51 void SetWritable() override; |
51 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override; | 52 QuicByteCount GetMaxPacketSize(const IPEndPoint& peer_address) const override; |
52 | 53 |
53 protected: | 54 protected: |
54 // Do not call WritePacket on its own -- use WritePacketWithCallback | 55 // Do not call WritePacket on its own -- use WritePacketWithCallback |
55 WriteResult WritePacket(const char* buffer, | 56 WriteResult WritePacket(const char* buffer, |
56 size_t buf_len, | 57 size_t buf_len, |
57 const IPAddressNumber& self_address, | 58 const IPAddressNumber& self_address, |
58 const IPEndPoint& peer_address) override; | 59 const IPEndPoint& peer_address, |
| 60 PerPacketOptions* options) override; |
59 | 61 |
60 private: | 62 private: |
61 UDPServerSocket* socket_; | 63 UDPServerSocket* socket_; |
62 | 64 |
63 // To be notified after every successful asynchronous write. | 65 // To be notified after every successful asynchronous write. |
64 QuicBlockedWriterInterface* blocked_writer_; | 66 QuicBlockedWriterInterface* blocked_writer_; |
65 | 67 |
66 // To call once the write completes. | 68 // To call once the write completes. |
67 WriteCallback callback_; | 69 WriteCallback callback_; |
68 | 70 |
69 // Whether a write is currently in flight. | 71 // Whether a write is currently in flight. |
70 bool write_blocked_; | 72 bool write_blocked_; |
71 | 73 |
72 base::WeakPtrFactory<QuicSimpleServerPacketWriter> weak_factory_; | 74 base::WeakPtrFactory<QuicSimpleServerPacketWriter> weak_factory_; |
73 | 75 |
74 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerPacketWriter); | 76 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerPacketWriter); |
75 }; | 77 }; |
76 | 78 |
77 } // namespace net | 79 } // namespace net |
78 | 80 |
79 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_ | 81 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_PACKET_WRITER_H_ |
OLD | NEW |