OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CHROMIUM_PACKET_WRITER_H_ | 5 #ifndef NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ |
6 #define NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ | 6 #define NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Delegate interface which receives notifications on socket write events. | 25 // Delegate interface which receives notifications on socket write events. |
26 class NET_EXPORT_PRIVATE Delegate { | 26 class NET_EXPORT_PRIVATE Delegate { |
27 public: | 27 public: |
28 // Called when a socket write attempt results in a failure, so | 28 // Called when a socket write attempt results in a failure, so |
29 // that the delegate may recover from it by perhaps rewriting the | 29 // that the delegate may recover from it by perhaps rewriting the |
30 // packet to a different socket. An implementation must return the | 30 // packet to a different socket. An implementation must return the |
31 // return value from the rewrite attempt if there is one, and | 31 // return value from the rewrite attempt if there is one, and |
32 // |error_code| otherwise. | 32 // |error_code| otherwise. |
33 virtual int HandleWriteError(int error_code, | 33 virtual int HandleWriteError(int error_code, |
34 scoped_refptr<StringIOBuffer> last_packet) = 0; | 34 scoped_refptr<StringIOBuffer> last_packet) = 0; |
| 35 |
35 // Called to propagate the final write error to the delegate. | 36 // Called to propagate the final write error to the delegate. |
36 virtual void OnWriteError(int error_code) = 0; | 37 virtual void OnWriteError(int error_code) = 0; |
| 38 |
37 // Called when the writer is unblocked due to a write completion. | 39 // Called when the writer is unblocked due to a write completion. |
38 virtual void OnWriteUnblocked() = 0; | 40 virtual void OnWriteUnblocked() = 0; |
39 }; | 41 }; |
40 | 42 |
41 QuicChromiumPacketWriter(); | 43 QuicChromiumPacketWriter(); |
42 // |socket| must outlive writer. | 44 // |socket| must outlive writer. |
43 explicit QuicChromiumPacketWriter(Socket* socket); | 45 explicit QuicChromiumPacketWriter(Socket* socket); |
44 ~QuicChromiumPacketWriter() override; | 46 ~QuicChromiumPacketWriter() override; |
45 | 47 |
46 // |delegate| must outlive writer. | 48 // |delegate| must outlive writer. |
47 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 49 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
48 | 50 |
49 // Writes |packet| to the socket and returns the error code from the write. | 51 // Writes |packet| to the socket and returns the error code from the write. |
50 int WritePacketToSocket(StringIOBuffer* packet); | 52 WriteResult WritePacketToSocket(scoped_refptr<StringIOBuffer> packet); |
51 | 53 |
52 // QuicPacketWriter | 54 // QuicPacketWriter |
53 WriteResult WritePacket(const char* buffer, | 55 WriteResult WritePacket(const char* buffer, |
54 size_t buf_len, | 56 size_t buf_len, |
55 const IPAddress& self_address, | 57 const IPAddress& self_address, |
56 const IPEndPoint& peer_address, | 58 const IPEndPoint& peer_address, |
57 PerPacketOptions* options) override; | 59 PerPacketOptions* options) override; |
58 bool IsWriteBlockedDataBuffered() const override; | 60 bool IsWriteBlockedDataBuffered() const override; |
59 bool IsWriteBlocked() const override; | 61 bool IsWriteBlocked() const override; |
60 void SetWritable() override; | 62 void SetWritable() override; |
(...skipping 15 matching lines...) Expand all Loading... |
76 bool write_blocked_; | 78 bool write_blocked_; |
77 | 79 |
78 base::WeakPtrFactory<QuicChromiumPacketWriter> weak_factory_; | 80 base::WeakPtrFactory<QuicChromiumPacketWriter> weak_factory_; |
79 | 81 |
80 DISALLOW_COPY_AND_ASSIGN(QuicChromiumPacketWriter); | 82 DISALLOW_COPY_AND_ASSIGN(QuicChromiumPacketWriter); |
81 }; | 83 }; |
82 | 84 |
83 } // namespace net | 85 } // namespace net |
84 | 86 |
85 #endif // NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ | 87 #endif // NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ |
OLD | NEW |