Chromium Code Reviews| Index: net/quic/chromium/quic_chromium_packet_writer.h |
| diff --git a/net/quic/chromium/quic_chromium_packet_writer.h b/net/quic/chromium/quic_chromium_packet_writer.h |
| index 8c0fc6a378d4889de74fd824ecc459cb0ac1cbcb..fbd10ef3008685e6d71a4b54b90e75499540e3e5 100644 |
| --- a/net/quic/chromium/quic_chromium_packet_writer.h |
| +++ b/net/quic/chromium/quic_chromium_packet_writer.h |
| @@ -22,22 +22,27 @@ namespace net { |
| // Chrome specific packet writer which uses a datagram Socket for writing data. |
| class NET_EXPORT_PRIVATE QuicChromiumPacketWriter : public QuicPacketWriter { |
| public: |
| - // Interface which receives notifications on socket write errors. |
| - class NET_EXPORT_PRIVATE WriteErrorObserver { |
| + // Delegate interface which receives notifications on socket write events. |
| + class NET_EXPORT_PRIVATE Delegate { |
| public: |
| - // Called on socket write error, with the error code of the failure |
| - // and the packet that was not written as a result of the failure. |
| - // An implementation must return error code from the rewrite |
| - // attempt if there was one, else return |error_code|. |
| - virtual int OnWriteError(int error_code, |
| - scoped_refptr<StringIOBuffer> last_packet) = 0; |
| + // Called when a socket write attempt results in a failure, so |
| + // that the delegate may recover from it by perhaps rewriting the |
| + // packet to a different socket. An implementation must return the |
| + // return value from the rewrite attempt if there is one, and |
| + // |error_code| otherwise. |
| + virtual int HandleWriteError(int error_code, |
| + scoped_refptr<StringIOBuffer> last_packet) = 0; |
| + // Called to propagate a write error to observers above of the final error. |
| + virtual void OnWriteError(int error_code) = 0; |
| + // Called when the writer is unblocked due to a write completion. |
| + virtual void OnWriteUnblocked() = 0; |
| }; |
| QuicChromiumPacketWriter(); |
| explicit QuicChromiumPacketWriter(Socket* socket); |
|
Ryan Hamilton
2016/09/09 02:56:23
I assume socket must outlive the writer? If so, pl
Jana
2016/09/09 04:19:34
Yes. The socket that's passed in is owned by QuicC
|
| ~QuicChromiumPacketWriter() override; |
| - void Initialize(WriteErrorObserver* observer, QuicConnection* connection); |
| + void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
|
Ryan Hamilton
2016/09/09 02:56:23
nit: Can you comment "// Must outlive the writer."
Jana
2016/09/09 04:19:34
Done.
|
| // Writes |packet| to the socket and returns the error code from the write. |
| int WritePacketToSocket(StringIOBuffer* packet); |
| @@ -60,8 +65,7 @@ class NET_EXPORT_PRIVATE QuicChromiumPacketWriter : public QuicPacketWriter { |
| private: |
| Socket* socket_; |
| - QuicConnection* connection_; |
| - WriteErrorObserver* observer_; |
| + Delegate* delegate_; |
|
Ryan Hamilton
2016/09/09 02:56:23
// Unowned.
(And above, assuming that's true)
Jana
2016/09/09 04:19:34
Done.
|
| // When a write returns asynchronously, |packet_| stores the written |
| // packet until OnWriteComplete is called. |
| scoped_refptr<StringIOBuffer> packet_; |