| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ | 5 #ifndef NET_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ |
| 6 #define NET_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ | 6 #define NET_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" |
| 16 #include "base/task.h" | 17 #include "base/task.h" |
| 17 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 19 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
| 20 #include "net/base/ssl_config_service.h" | 21 #include "net/base/ssl_config_service.h" |
| 21 #include "net/base/upload_data_stream.h" | 22 #include "net/base/upload_data_stream.h" |
| 22 #include "net/http/http_pipelined_connection.h" | 23 #include "net/http/http_pipelined_connection.h" |
| 23 #include "net/http/http_request_info.h" | 24 #include "net/http/http_request_info.h" |
| 24 #include "net/http/http_stream_parser.h" | 25 #include "net/http/http_stream_parser.h" |
| 25 #include "net/proxy/proxy_info.h" | 26 #include "net/proxy/proxy_info.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // pass-through methods in HttpPipelinedStream. | 80 // pass-through methods in HttpPipelinedStream. |
| 80 void InitializeParser(int pipeline_id, | 81 void InitializeParser(int pipeline_id, |
| 81 const HttpRequestInfo* request, | 82 const HttpRequestInfo* request, |
| 82 const BoundNetLog& net_log); | 83 const BoundNetLog& net_log); |
| 83 | 84 |
| 84 int SendRequest(int pipeline_id, | 85 int SendRequest(int pipeline_id, |
| 85 const std::string& request_line, | 86 const std::string& request_line, |
| 86 const HttpRequestHeaders& headers, | 87 const HttpRequestHeaders& headers, |
| 87 UploadDataStream* request_body, | 88 UploadDataStream* request_body, |
| 88 HttpResponseInfo* response, | 89 HttpResponseInfo* response, |
| 89 OldCompletionCallback* callback); | 90 const CompletionCallback& callback); |
| 90 | 91 |
| 91 int ReadResponseHeaders(int pipeline_id, | 92 int ReadResponseHeaders(int pipeline_id, |
| 92 OldCompletionCallback* callback); | 93 const CompletionCallback& callback); |
| 93 | 94 |
| 94 int ReadResponseBody(int pipeline_id, | 95 int ReadResponseBody(int pipeline_id, |
| 95 IOBuffer* buf, int buf_len, | 96 IOBuffer* buf, int buf_len, |
| 96 OldCompletionCallback* callback); | 97 const CompletionCallback& callback); |
| 97 | 98 |
| 98 void Close(int pipeline_id, | 99 void Close(int pipeline_id, |
| 99 bool not_reusable); | 100 bool not_reusable); |
| 100 | 101 |
| 101 uint64 GetUploadProgress(int pipeline_id) const; | 102 uint64 GetUploadProgress(int pipeline_id) const; |
| 102 | 103 |
| 103 HttpResponseInfo* GetResponseInfo(int pipeline_id); | 104 HttpResponseInfo* GetResponseInfo(int pipeline_id); |
| 104 | 105 |
| 105 bool IsResponseBodyComplete(int pipeline_id) const; | 106 bool IsResponseBodyComplete(int pipeline_id) const; |
| 106 | 107 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 156 |
| 156 struct PendingSendRequest { | 157 struct PendingSendRequest { |
| 157 PendingSendRequest(); | 158 PendingSendRequest(); |
| 158 ~PendingSendRequest(); | 159 ~PendingSendRequest(); |
| 159 | 160 |
| 160 int pipeline_id; | 161 int pipeline_id; |
| 161 std::string request_line; | 162 std::string request_line; |
| 162 HttpRequestHeaders headers; | 163 HttpRequestHeaders headers; |
| 163 UploadDataStream* request_body; | 164 UploadDataStream* request_body; |
| 164 HttpResponseInfo* response; | 165 HttpResponseInfo* response; |
| 165 OldCompletionCallback* callback; | 166 CompletionCallback callback; |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 struct StreamInfo { | 169 struct StreamInfo { |
| 169 StreamInfo(); | 170 StreamInfo(); |
| 170 ~StreamInfo(); | 171 ~StreamInfo(); |
| 171 | 172 |
| 172 linked_ptr<HttpStreamParser> parser; | 173 linked_ptr<HttpStreamParser> parser; |
| 173 OldCompletionCallback* read_headers_callback; | 174 CompletionCallback read_headers_callback; |
| 174 OldCompletionCallback* pending_user_callback; | 175 CompletionCallback pending_user_callback; |
| 175 StreamState state; | 176 StreamState state; |
| 176 }; | 177 }; |
| 177 | 178 |
| 178 typedef std::map<int, StreamInfo> StreamInfoMap; | 179 typedef std::map<int, StreamInfo> StreamInfoMap; |
| 179 | 180 |
| 180 // Called after the first request is sent or in a task sometime after the | 181 // Called after the first request is sent or in a task sometime after the |
| 181 // first stream is added to this pipeline. This gives the first request | 182 // first stream is added to this pipeline. This gives the first request |
| 182 // priority to send, but doesn't hold up other requests if it doesn't. | 183 // priority to send, but doesn't hold up other requests if it doesn't. |
| 183 // When called the first time, notifies the |delegate_| that we can accept new | 184 // When called the first time, notifies the |delegate_| that we can accept new |
| 184 // requests. | 185 // requests. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // every time we receive headers. | 261 // every time we receive headers. |
| 261 void CheckHeadersForPipelineCompatibility(int result, int pipeline_id); | 262 void CheckHeadersForPipelineCompatibility(int result, int pipeline_id); |
| 262 | 263 |
| 263 // Posts a task to fire the user's callback in response to SendRequest() or | 264 // Posts a task to fire the user's callback in response to SendRequest() or |
| 264 // ReadResponseHeaders() completing on an underlying parser. This might be | 265 // ReadResponseHeaders() completing on an underlying parser. This might be |
| 265 // invoked in response to our own IO callbacks, or it may be invoked if the | 266 // invoked in response to our own IO callbacks, or it may be invoked if the |
| 266 // underlying parser completes SendRequest() or ReadResponseHeaders() | 267 // underlying parser completes SendRequest() or ReadResponseHeaders() |
| 267 // synchronously, but we've already returned ERR_IO_PENDING to the user's | 268 // synchronously, but we've already returned ERR_IO_PENDING to the user's |
| 268 // SendRequest() or ReadResponseHeaders() call into us. | 269 // SendRequest() or ReadResponseHeaders() call into us. |
| 269 void QueueUserCallback(int pipeline_id, | 270 void QueueUserCallback(int pipeline_id, |
| 270 OldCompletionCallback* callback, | 271 const CompletionCallback& callback, |
| 271 int rv, | 272 int rv, |
| 272 const tracked_objects::Location& from_here); | 273 const tracked_objects::Location& from_here); |
| 273 | 274 |
| 274 // Invokes the callback queued in QueueUserCallback(). | 275 // Invokes the callback queued in QueueUserCallback(). |
| 275 void FireUserCallback(int pipeline_id, int result); | 276 void FireUserCallback(int pipeline_id, int result); |
| 276 | 277 |
| 277 Delegate* delegate_; | 278 Delegate* delegate_; |
| 278 scoped_ptr<ClientSocketHandle> connection_; | 279 scoped_ptr<ClientSocketHandle> connection_; |
| 279 SSLConfig used_ssl_config_; | 280 SSLConfig used_ssl_config_; |
| 280 ProxyInfo used_proxy_info_; | 281 ProxyInfo used_proxy_info_; |
| 281 BoundNetLog net_log_; | 282 BoundNetLog net_log_; |
| 282 bool was_npn_negotiated_; | 283 bool was_npn_negotiated_; |
| 283 scoped_refptr<GrowableIOBuffer> read_buf_; | 284 scoped_refptr<GrowableIOBuffer> read_buf_; |
| 284 int next_pipeline_id_; | 285 int next_pipeline_id_; |
| 285 bool active_; | 286 bool active_; |
| 286 bool usable_; | 287 bool usable_; |
| 287 bool completed_one_request_; | 288 bool completed_one_request_; |
| 288 ScopedRunnableMethodFactory<HttpPipelinedConnectionImpl> method_factory_; | 289 base::WeakPtrFactory<HttpPipelinedConnectionImpl> weak_factory_; |
| 289 | 290 |
| 290 StreamInfoMap stream_info_map_; | 291 StreamInfoMap stream_info_map_; |
| 291 | 292 |
| 292 std::queue<int> request_order_; | 293 std::queue<int> request_order_; |
| 293 | 294 |
| 294 std::queue<PendingSendRequest*> pending_send_request_queue_; | 295 std::queue<PendingSendRequest*> pending_send_request_queue_; |
| 295 scoped_ptr<PendingSendRequest> active_send_request_; | 296 scoped_ptr<PendingSendRequest> active_send_request_; |
| 296 SendRequestState send_next_state_; | 297 SendRequestState send_next_state_; |
| 297 bool send_still_on_call_stack_; | 298 bool send_still_on_call_stack_; |
| 298 OldCompletionCallbackImpl<HttpPipelinedConnectionImpl> send_io_callback_; | |
| 299 | 299 |
| 300 ReadHeadersState read_next_state_; | 300 ReadHeadersState read_next_state_; |
| 301 int active_read_id_; | 301 int active_read_id_; |
| 302 bool read_still_on_call_stack_; | 302 bool read_still_on_call_stack_; |
| 303 OldCompletionCallbackImpl<HttpPipelinedConnectionImpl> read_io_callback_; | |
| 304 | 303 |
| 305 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedConnectionImpl); | 304 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedConnectionImpl); |
| 306 }; | 305 }; |
| 307 | 306 |
| 308 } // namespace net | 307 } // namespace net |
| 309 | 308 |
| 310 #endif // NET_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ | 309 #endif // NET_HTTP_HTTP_PIPELINED_CONNECTION_IMPL_H_ |
| OLD | NEW |