OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/http/http_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/http/http_network_session.h" | 10 #include "net/http/http_network_session.h" |
11 #include "net/http/http_proxy_client_socket.h" | 11 #include "net/http/http_proxy_client_socket.h" |
12 #include "net/socket/client_socket_factory.h" | 12 #include "net/socket/client_socket_factory.h" |
13 #include "net/socket/client_socket_handle.h" | 13 #include "net/socket/client_socket_handle.h" |
14 #include "net/socket/client_socket_pool_base.h" | 14 #include "net/socket/client_socket_pool_base.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 HttpProxySocketParams::HttpProxySocketParams( | 18 HttpProxySocketParams::HttpProxySocketParams( |
19 const scoped_refptr<TCPSocketParams>& proxy_server, | 19 const scoped_refptr<TCPSocketParams>& proxy_server, |
20 const GURL& request_url, | 20 const GURL& request_url, |
21 HostPortPair endpoint, | 21 HostPortPair endpoint, |
22 scoped_refptr<HttpNetworkSession> session, | 22 scoped_refptr<HttpNetworkSession> session, |
23 bool tunnel) | 23 bool tunnel) |
24 : tcp_params_(proxy_server), | 24 : tcp_params_(proxy_server), |
25 request_url_(request_url), | 25 request_url_(request_url), |
26 endpoint_(endpoint), | 26 endpoint_(endpoint), |
27 session_(session), | 27 session_(tunnel ? session : NULL), |
28 tunnel_(tunnel) { | 28 tunnel_(tunnel) { |
29 } | 29 } |
30 | 30 |
31 HttpProxySocketParams::~HttpProxySocketParams() {} | 31 HttpProxySocketParams::~HttpProxySocketParams() {} |
32 | 32 |
33 // HttpProxyConnectJobs will time out after this many seconds. Note this is on | 33 // HttpProxyConnectJobs will time out after this many seconds. Note this is on |
34 // top of the timeout for the transport socket. | 34 // top of the timeout for the transport socket. |
35 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; | 35 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; |
36 | 36 |
37 HttpProxyConnectJob::HttpProxyConnectJob( | 37 HttpProxyConnectJob::HttpProxyConnectJob( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 HostPortPair proxy_server(tcp_destination.hostname(), | 139 HostPortPair proxy_server(tcp_destination.hostname(), |
140 tcp_destination.port()); | 140 tcp_destination.port()); |
141 | 141 |
142 // Add a HttpProxy connection on top of the tcp socket. | 142 // Add a HttpProxy connection on top of the tcp socket. |
143 socket_.reset(new HttpProxyClientSocket(tcp_socket_handle_.release(), | 143 socket_.reset(new HttpProxyClientSocket(tcp_socket_handle_.release(), |
144 params_->request_url(), | 144 params_->request_url(), |
145 params_->endpoint(), | 145 params_->endpoint(), |
146 proxy_server, | 146 proxy_server, |
147 params_->session(), | 147 params_->session(), |
148 params_->tunnel())); | 148 params_->tunnel())); |
149 return socket_->Connect(&callback_); | 149 int result = socket_->Connect(&callback_); |
| 150 |
| 151 // Clear the circular reference to HttpNetworkSession (|params_| reference |
| 152 // HttpNetworkSession, which reference HttpProxyClientSocketPool, which |
| 153 // references |this|) here because it is safe to do so now but not at other |
| 154 // points. This may cancel this ConnectJob. |
| 155 params_ = NULL; |
| 156 return result; |
150 } | 157 } |
151 | 158 |
152 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { | 159 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { |
153 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED) | 160 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED) |
154 set_socket(socket_.release()); | 161 set_socket(socket_.release()); |
155 | 162 |
156 return result; | 163 return result; |
157 } | 164 } |
158 | 165 |
159 ConnectJob* | 166 ConnectJob* |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 const std::string& group_name) const { | 231 const std::string& group_name) const { |
225 return base_.IdleSocketCountInGroup(group_name); | 232 return base_.IdleSocketCountInGroup(group_name); |
226 } | 233 } |
227 | 234 |
228 LoadState HttpProxyClientSocketPool::GetLoadState( | 235 LoadState HttpProxyClientSocketPool::GetLoadState( |
229 const std::string& group_name, const ClientSocketHandle* handle) const { | 236 const std::string& group_name, const ClientSocketHandle* handle) const { |
230 return base_.GetLoadState(group_name, handle); | 237 return base_.GetLoadState(group_name, handle); |
231 } | 238 } |
232 | 239 |
233 } // namespace net | 240 } // namespace net |
OLD | NEW |