| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
| 14 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
| 15 #include "net/http/http_stream.h" | 15 #include "net/http/http_stream.h" |
| 16 #include "net/spdy/spdy_read_queue.h" |
| 16 #include "net/spdy/spdy_stream.h" | 17 #include "net/spdy/spdy_stream.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 class DrainableIOBuffer; | 21 class DrainableIOBuffer; |
| 21 struct HttpRequestInfo; | 22 struct HttpRequestInfo; |
| 22 class HttpResponseInfo; | 23 class HttpResponseInfo; |
| 23 class IOBuffer; | 24 class IOBuffer; |
| 24 class SpdySession; | 25 class SpdySession; |
| 25 class UploadDataStream; | 26 class UploadDataStream; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual void Drain(HttpNetworkSession* session) OVERRIDE; | 83 virtual void Drain(HttpNetworkSession* session) OVERRIDE; |
| 83 | 84 |
| 84 // SpdyStream::Delegate implementation. | 85 // SpdyStream::Delegate implementation. |
| 85 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; | 86 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; |
| 86 virtual int OnSendBody() OVERRIDE; | 87 virtual int OnSendBody() OVERRIDE; |
| 87 virtual SpdySendStatus OnSendBodyComplete(size_t bytes_sent) OVERRIDE; | 88 virtual SpdySendStatus OnSendBodyComplete(size_t bytes_sent) OVERRIDE; |
| 88 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 89 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 89 base::Time response_time, | 90 base::Time response_time, |
| 90 int status) OVERRIDE; | 91 int status) OVERRIDE; |
| 91 virtual void OnHeadersSent() OVERRIDE; | 92 virtual void OnHeadersSent() OVERRIDE; |
| 92 virtual int OnDataReceived(const char* buffer, int bytes) OVERRIDE; | 93 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; |
| 93 virtual void OnDataSent(size_t bytes_sent) OVERRIDE; | 94 virtual void OnDataSent(size_t bytes_sent) OVERRIDE; |
| 94 virtual void OnClose(int status) OVERRIDE; | 95 virtual void OnClose(int status) OVERRIDE; |
| 95 | 96 |
| 96 private: | 97 private: |
| 97 void OnStreamCreated(const CompletionCallback& callback, int rv); | 98 void OnStreamCreated(const CompletionCallback& callback, int rv); |
| 98 | 99 |
| 99 // Reads the data (whether chunked or not) from the request body stream and | 100 // Reads the data (whether chunked or not) from the request body stream and |
| 100 // sends the data by calling WriteStreamData on the underlying SpdyStream. | 101 // sends the data by calling WriteStreamData on the underlying SpdyStream. |
| 101 int SendData(); | 102 int SendData(); |
| 102 | 103 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 133 // when a SYN_REPLY comes in for the stream. | 134 // when a SYN_REPLY comes in for the stream. |
| 134 // It is not owned by this stream object, or point to |push_response_info_|. | 135 // It is not owned by this stream object, or point to |push_response_info_|. |
| 135 HttpResponseInfo* response_info_; | 136 HttpResponseInfo* response_info_; |
| 136 | 137 |
| 137 scoped_ptr<HttpResponseInfo> push_response_info_; | 138 scoped_ptr<HttpResponseInfo> push_response_info_; |
| 138 | 139 |
| 139 bool response_headers_received_; // Indicates waiting for more HEADERS. | 140 bool response_headers_received_; // Indicates waiting for more HEADERS. |
| 140 | 141 |
| 141 // We buffer the response body as it arrives asynchronously from the stream. | 142 // We buffer the response body as it arrives asynchronously from the stream. |
| 142 // TODO(mbelshe): is this infinite buffering? | 143 // TODO(mbelshe): is this infinite buffering? |
| 143 std::list<scoped_refptr<IOBufferWithSize> > response_body_; | 144 SpdyReadQueue response_body_queue_; |
| 144 | 145 |
| 145 CompletionCallback callback_; | 146 CompletionCallback callback_; |
| 146 | 147 |
| 147 // User provided buffer for the ReadResponseBody() response. | 148 // User provided buffer for the ReadResponseBody() response. |
| 148 scoped_refptr<IOBuffer> user_buffer_; | 149 scoped_refptr<IOBuffer> user_buffer_; |
| 149 int user_buffer_len_; | 150 int user_buffer_len_; |
| 150 | 151 |
| 151 // Temporary buffer used to read the request body from UploadDataStream. | 152 // Temporary buffer used to read the request body from UploadDataStream. |
| 152 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; | 153 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; |
| 153 // Wraps raw_request_body_buf_ to read the remaining data progressively. | 154 // Wraps raw_request_body_buf_ to read the remaining data progressively. |
| 154 scoped_refptr<DrainableIOBuffer> request_body_buf_; | 155 scoped_refptr<DrainableIOBuffer> request_body_buf_; |
| 155 | 156 |
| 156 // Is there a scheduled read callback pending. | 157 // Is there a scheduled read callback pending. |
| 157 bool buffered_read_callback_pending_; | 158 bool buffered_read_callback_pending_; |
| 158 // 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 |
| 159 // scheduled read callback. | 160 // scheduled read callback. |
| 160 bool more_read_data_pending_; | 161 bool more_read_data_pending_; |
| 161 | 162 |
| 162 // 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). |
| 163 bool direct_; | 164 bool direct_; |
| 164 | 165 |
| 165 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 166 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 } // namespace net | 169 } // namespace net |
| 169 | 170 |
| 170 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 171 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
| OLD | NEW |