| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SPDY_SPDY_HTTP_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ | 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 virtual bool IsConnectionReusable() const OVERRIDE; | 78 virtual bool IsConnectionReusable() const OVERRIDE; |
| 79 virtual bool GetLoadTimingInfo( | 79 virtual bool GetLoadTimingInfo( |
| 80 LoadTimingInfo* load_timing_info) const OVERRIDE; | 80 LoadTimingInfo* load_timing_info) const OVERRIDE; |
| 81 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | 81 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; |
| 82 virtual void GetSSLCertRequestInfo( | 82 virtual void GetSSLCertRequestInfo( |
| 83 SSLCertRequestInfo* cert_request_info) OVERRIDE; | 83 SSLCertRequestInfo* cert_request_info) OVERRIDE; |
| 84 virtual bool IsSpdyHttpStream() const OVERRIDE; | 84 virtual bool IsSpdyHttpStream() const OVERRIDE; |
| 85 virtual void Drain(HttpNetworkSession* session) OVERRIDE; | 85 virtual void Drain(HttpNetworkSession* session) OVERRIDE; |
| 86 | 86 |
| 87 // SpdyStream::Delegate implementation. | 87 // SpdyStream::Delegate implementation. |
| 88 virtual void OnSendRequestHeadersComplete() OVERRIDE; | 88 virtual void OnRequestHeadersSent() OVERRIDE; |
| 89 virtual void OnSendBody() OVERRIDE; | 89 virtual int OnResponseHeadersReceived(const SpdyHeaderBlock& response, |
| 90 virtual void OnSendBodyComplete() OVERRIDE; | 90 base::Time response_time, |
| 91 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 91 int status) OVERRIDE; |
| 92 base::Time response_time, | |
| 93 int status) OVERRIDE; | |
| 94 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; | 92 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; |
| 95 virtual void OnDataSent() OVERRIDE; | 93 virtual void OnDataSent() OVERRIDE; |
| 96 virtual void OnClose(int status) OVERRIDE; | 94 virtual void OnClose(int status) OVERRIDE; |
| 97 | 95 |
| 98 private: | 96 private: |
| 97 bool HasUploadData() const; |
| 98 |
| 99 void OnStreamCreated(const CompletionCallback& callback, int rv); | 99 void OnStreamCreated(const CompletionCallback& callback, int rv); |
| 100 | 100 |
| 101 // Reads the data (whether chunked or not) from the request body | 101 // Reads the remaining data (whether chunked or not) from the |
| 102 // stream and sends it. The read and subsequent sending may happen | 102 // request body stream and sends it if there's any. The read and |
| 103 // asynchronously. | 103 // subsequent sending may happen asynchronously. Must be called only |
| 104 // when HasUploadData() is true. |
| 104 void ReadAndSendRequestBodyData(); | 105 void ReadAndSendRequestBodyData(); |
| 105 | 106 |
| 106 // Called when data has just been read from the request body stream; | 107 // Called when data has just been read from the request body stream; |
| 107 // does the actual sending of data. | 108 // does the actual sending of data. |
| 108 void OnRequestBodyReadCompleted(int status); | 109 void OnRequestBodyReadCompleted(int status); |
| 109 | 110 |
| 110 // Queues some request body data to be sent. | |
| 111 void SendRequestBodyData(); | |
| 112 | |
| 113 // Call the user callback. | 111 // Call the user callback. |
| 114 void DoCallback(int rv); | 112 void DoCallback(int rv); |
| 115 | 113 |
| 116 void ScheduleBufferedReadCallback(); | 114 void ScheduleBufferedReadCallback(); |
| 117 | 115 |
| 118 // Returns true if the callback is invoked. | 116 // Returns true if the callback is invoked. |
| 119 bool DoBufferedReadCallback(); | 117 bool DoBufferedReadCallback(); |
| 120 bool ShouldWaitForMoreBufferedData() const; | 118 bool ShouldWaitForMoreBufferedData() const; |
| 121 | 119 |
| 122 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; | 120 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; |
| 123 | 121 |
| 124 const scoped_refptr<SpdySession> spdy_session_; | 122 const scoped_refptr<SpdySession> spdy_session_; |
| 125 SpdyStreamRequest stream_request_; | 123 SpdyStreamRequest stream_request_; |
| 126 base::WeakPtr<SpdyStream> stream_; | 124 base::WeakPtr<SpdyStream> stream_; |
| 127 | 125 |
| 128 bool stream_closed_; | 126 bool stream_closed_; |
| 129 | 127 |
| 130 // Set only when |stream_closed_| is true. | 128 // Set only when |stream_closed_| is true. |
| 131 int closed_stream_status_; | 129 int closed_stream_status_; |
| 132 SpdyStreamId closed_stream_id_; | 130 SpdyStreamId closed_stream_id_; |
| 133 | 131 |
| 134 // The request to send. | 132 // The request to send. |
| 135 const HttpRequestInfo* request_info_; | 133 const HttpRequestInfo* request_info_; |
| 136 | 134 |
| 137 bool has_upload_data_; | |
| 138 | |
| 139 // |response_info_| is the HTTP response data object which is filled in | 135 // |response_info_| is the HTTP response data object which is filled in |
| 140 // when a SYN_REPLY comes in for the stream. | 136 // when a SYN_REPLY comes in for the stream. |
| 141 // It is not owned by this stream object, or point to |push_response_info_|. | 137 // It is not owned by this stream object, or point to |push_response_info_|. |
| 142 HttpResponseInfo* response_info_; | 138 HttpResponseInfo* response_info_; |
| 143 | 139 |
| 144 scoped_ptr<HttpResponseInfo> push_response_info_; | 140 scoped_ptr<HttpResponseInfo> push_response_info_; |
| 145 | 141 |
| 146 bool response_headers_received_; // Indicates waiting for more HEADERS. | 142 bool response_headers_received_; // Indicates waiting for more HEADERS. |
| 147 | 143 |
| 148 // We buffer the response body as it arrives asynchronously from the stream. | 144 // We buffer the response body as it arrives asynchronously from the stream. |
| 149 SpdyReadQueue response_body_queue_; | 145 SpdyReadQueue response_body_queue_; |
| 150 | 146 |
| 151 CompletionCallback callback_; | 147 CompletionCallback callback_; |
| 152 | 148 |
| 153 // User provided buffer for the ReadResponseBody() response. | 149 // User provided buffer for the ReadResponseBody() response. |
| 154 scoped_refptr<IOBuffer> user_buffer_; | 150 scoped_refptr<IOBuffer> user_buffer_; |
| 155 int user_buffer_len_; | 151 int user_buffer_len_; |
| 156 | 152 |
| 157 // Temporary buffer used to read the request body from UploadDataStream. | 153 // Temporary buffer used to read the request body from UploadDataStream. |
| 158 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; | 154 scoped_refptr<IOBufferWithSize> request_body_buf_; |
| 159 int raw_request_body_buf_size_; | 155 int request_body_buf_size_; |
| 160 | 156 |
| 161 // Is there a scheduled read callback pending. | 157 // Is there a scheduled read callback pending. |
| 162 bool buffered_read_callback_pending_; | 158 bool buffered_read_callback_pending_; |
| 163 // Has more data been received from the network during the wait for the | 159 // Has more data been received from the network during the wait for the |
| 164 // scheduled read callback. | 160 // scheduled read callback. |
| 165 bool more_read_data_pending_; | 161 bool more_read_data_pending_; |
| 166 | 162 |
| 167 // Is this spdy stream direct to the origin server (or to a proxy). | 163 // Is this spdy stream direct to the origin server (or to a proxy). |
| 168 bool direct_; | 164 bool direct_; |
| 169 | 165 |
| 170 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 166 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
| 171 }; | 167 }; |
| 172 | 168 |
| 173 } // namespace net | 169 } // namespace net |
| 174 | 170 |
| 175 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 171 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
| OLD | NEW |