Chromium Code Reviews| Index: net/quic/chromium/quic_chromium_client_stream.h |
| diff --git a/net/quic/chromium/quic_chromium_client_stream.h b/net/quic/chromium/quic_chromium_client_stream.h |
| index e95d47840629d81a4c5940db3c8f7877a47ce6a0..a29e118a670198e2ed850b1282c047661a4c6e3e 100644 |
| --- a/net/quic/chromium/quic_chromium_client_stream.h |
| +++ b/net/quic/chromium/quic_chromium_client_stream.h |
| @@ -32,26 +32,6 @@ class QuicClientSessionBase; |
| // are owned by the QuicClientSession which created them. |
| class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| public: |
| - // TODO(rch): Remove this class completely in favor of async methods |
| - // on the Handle. |
| - // Delegate handles protocol specific behavior of a quic stream. |
| - class NET_EXPORT_PRIVATE Delegate { |
| - public: |
| - Delegate() {} |
| - |
| - // Called when the stream is closed by the peer. |
| - virtual void OnClose() = 0; |
| - |
| - // Called when the stream is closed because of an error. |
| - virtual void OnError(int error) = 0; |
| - |
| - protected: |
| - virtual ~Delegate() {} |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(Delegate); |
| - }; |
| - |
| // Wrapper for interacting with the session in a restricted fashion. |
| class NET_EXPORT_PRIVATE Handle { |
| public: |
| @@ -90,10 +70,10 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| // Writes |header_block| to the peer. Closes the write side if |fin| is |
| // true. If non-null, |ack_notifier_delegate| will be notified when the |
| // headers are ACK'd by the peer. |
| - size_t WriteHeaders(SpdyHeaderBlock header_block, |
| - bool fin, |
| - QuicReferenceCountedPointer<QuicAckListenerInterface> |
| - ack_notifier_delegate); |
| + int WriteHeaders(SpdyHeaderBlock header_block, |
|
xunjieli
2017/05/31 00:25:22
Could you add a comment here mentioning that the r
Ryan Hamilton
2017/05/31 02:49:56
Done.
|
| + bool fin, |
| + QuicReferenceCountedPointer<QuicAckListenerInterface> |
| + ack_notifier_delegate); |
| // Writes |data| to the peer. Closes the write side if |fin| is true. |
| // If the data could not be written immediately, returns ERR_IO_PENDING |
| @@ -126,10 +106,6 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| // Sends a RST_STREAM frame to the peer and closes the streams. |
| void Reset(QuicRstStreamErrorCode error_code); |
| - // Clears |delegate_| from this Handle, but does not disconnect the Handle |
| - // from |stream_|. |
| - void ClearDelegate(); |
| - |
| QuicStreamId id() const; |
| QuicErrorCode connection_error() const; |
| QuicRstStreamErrorCode stream_error() const; |
| @@ -148,14 +124,11 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| SpdyPriority priority() const; |
| bool can_migrate(); |
| - Delegate* GetDelegate(); |
| - |
| private: |
| friend class QuicChromiumClientStream; |
| - // Constucts a new Handle for |stream| with |delegate| set to receive |
| - // up calls on various events. |
| - Handle(QuicChromiumClientStream* stream, Delegate* delegate); |
| + // Constucts a new Handle for |stream|. |
| + explicit Handle(QuicChromiumClientStream* stream); |
| // Methods invoked by the stream. |
| void OnInitialHeadersAvailable(); |
| @@ -165,11 +138,22 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| void OnClose(); |
| void OnError(int error); |
| + // Invokes async IO callbacks because of |error|. |
| + void InvokeCallbacksOnError(int error); |
| + |
| // Saves various fields from the stream before the stream goes away. |
| void SaveState(); |
| + void SetCallback(CompletionCallback new_callback, |
| + CompletionCallback* callback); |
| + |
| + void ResetAndRun(CompletionCallback* callback, int rv); |
| + |
| + int HandleIOComplete(int rv); |
| + |
| QuicChromiumClientStream* stream_; // Unowned. |
| - Delegate* delegate_; // Owns this. |
| + |
| + bool may_invoke_callbacks_; // True when callbacks may be invoked. |
| // Callback to be invoked when ReadHeaders completes asynchronously. |
| CompletionCallback read_headers_callback_; |
| @@ -196,6 +180,10 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| size_t num_bytes_consumed_; |
| SpdyPriority priority_; |
| + int net_error_; |
| + |
| + base::WeakPtrFactory<Handle> weak_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(Handle); |
| }; |
| @@ -238,10 +226,8 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| const std::vector<int>& lengths, |
| bool fin); |
| - // Creates a new Handle for this stream and sets |delegate| on the handle. |
| - // Must only be called once. |
| - std::unique_ptr<QuicChromiumClientStream::Handle> CreateHandle( |
| - QuicChromiumClientStream::Delegate* delegate); |
| + // Creates a new Handle for this stream. Must only be called once. |
| + std::unique_ptr<QuicChromiumClientStream::Handle> CreateHandle(); |
| // Clears |handle_| from this stream. |
| void ClearHandle(); |
| @@ -290,7 +276,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientStream : public QuicSpdyStream { |
| // Set to false if this stream to not be migrated during connection migration. |
| bool can_migrate_; |
| - // Stores the initial header if they arrive before the delegate. |
| + // Stores the initial header if they arrive before the handle. |
| SpdyHeaderBlock initial_headers_; |
| // Length of the HEADERS frame containing initial headers. |
| size_t initial_headers_frame_len_; |