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 #include "jingle/notifier/base/proxy_resolving_client_socket.h" | 5 #include "jingle/notifier/base/proxy_resolving_client_socket.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
16 #include "net/socket/client_socket_handle.h" | 16 #include "net/socket/client_socket_handle.h" |
17 #include "net/socket/client_socket_pool_manager.h" | 17 #include "net/socket/client_socket_pool_manager.h" |
18 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
20 | 20 |
21 namespace notifier { | 21 namespace notifier { |
22 | 22 |
23 namespace { | |
24 | |
25 void HandleProxyTunnelAuth(const net::HttpResponseInfo& response_info, | |
26 net::HttpAuthController* auth_controller, | |
27 net::CompletionCallback callback) { | |
28 // Since have not way to respond, simply invoke the callback and the | |
akalin
2012/01/20 01:45:56
Have not way -> we have no way
Ryan Hamilton
2012/01/20 03:51:02
Done.
| |
29 // request will fail. | |
30 callback.Run(net::OK); | |
31 } | |
32 | |
33 } // namespace | |
34 | |
23 ProxyResolvingClientSocket::ProxyResolvingClientSocket( | 35 ProxyResolvingClientSocket::ProxyResolvingClientSocket( |
24 net::ClientSocketFactory* socket_factory, | 36 net::ClientSocketFactory* socket_factory, |
25 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 37 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
26 const net::SSLConfig& ssl_config, | 38 const net::SSLConfig& ssl_config, |
27 const net::HostPortPair& dest_host_port_pair) | 39 const net::HostPortPair& dest_host_port_pair) |
28 : ALLOW_THIS_IN_INITIALIZER_LIST(proxy_resolve_callback_( | 40 : ALLOW_THIS_IN_INITIALIZER_LIST(proxy_resolve_callback_( |
29 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, | 41 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, |
30 base::Unretained(this)))), | 42 base::Unretained(this)))), |
31 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( | 43 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( |
32 base::Bind(&ProxyResolvingClientSocket::ProcessConnectDone, | 44 base::Bind(&ProxyResolvingClientSocket::ProcessConnectDone, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 CloseTransportSocket(); | 177 CloseTransportSocket(); |
166 RunUserConnectCallback(status); | 178 RunUserConnectCallback(status); |
167 return; | 179 return; |
168 } | 180 } |
169 } | 181 } |
170 | 182 |
171 transport_.reset(new net::ClientSocketHandle); | 183 transport_.reset(new net::ClientSocketHandle); |
172 // Now that we have resolved the proxy, we need to connect. | 184 // Now that we have resolved the proxy, we need to connect. |
173 status = net::InitSocketHandleForRawConnect( | 185 status = net::InitSocketHandleForRawConnect( |
174 dest_host_port_pair_, network_session_.get(), proxy_info_, ssl_config_, | 186 dest_host_port_pair_, network_session_.get(), proxy_info_, ssl_config_, |
175 ssl_config_, bound_net_log_, transport_.get(), connect_callback_); | 187 ssl_config_, bound_net_log_, transport_.get(), |
188 base::Bind(&HandleProxyTunnelAuth), connect_callback_); | |
189 | |
176 if (status != net::ERR_IO_PENDING) { | 190 if (status != net::ERR_IO_PENDING) { |
177 // Since this method is always called asynchronously. it is OK to call | 191 // Since this method is always called asynchronously. it is OK to call |
178 // ProcessConnectDone synchronously. | 192 // ProcessConnectDone synchronously. |
179 ProcessConnectDone(status); | 193 ProcessConnectDone(status); |
180 } | 194 } |
181 } | 195 } |
182 | 196 |
197 | |
183 void ProxyResolvingClientSocket::ProcessConnectDone(int status) { | 198 void ProxyResolvingClientSocket::ProcessConnectDone(int status) { |
akalin
2012/01/20 01:45:56
Remove extra space
Ryan Hamilton
2012/01/20 03:51:02
Done.
| |
184 if (status != net::OK) { | 199 if (status != net::OK) { |
185 // If the connection fails, try another proxy. | 200 // If the connection fails, try another proxy. |
186 status = ReconsiderProxyAfterError(status); | 201 status = ReconsiderProxyAfterError(status); |
187 // ReconsiderProxyAfterError either returns an error (in which case it is | 202 // ReconsiderProxyAfterError either returns an error (in which case it is |
188 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering | 203 // not reconsidering a proxy) or returns ERR_IO_PENDING if it is considering |
189 // another proxy. | 204 // another proxy. |
190 DCHECK_NE(status, net::OK); | 205 DCHECK_NE(status, net::OK); |
191 if (status == net::ERR_IO_PENDING) | 206 if (status == net::ERR_IO_PENDING) |
192 // Proxy reconsideration pending. Return. | 207 // Proxy reconsideration pending. Return. |
193 return; | 208 return; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 return base::TimeDelta::FromMicroseconds(-1); | 381 return base::TimeDelta::FromMicroseconds(-1); |
367 } | 382 } |
368 | 383 |
369 void ProxyResolvingClientSocket::CloseTransportSocket() { | 384 void ProxyResolvingClientSocket::CloseTransportSocket() { |
370 if (transport_.get() && transport_->socket()) | 385 if (transport_.get() && transport_->socket()) |
371 transport_->socket()->Disconnect(); | 386 transport_->socket()->Disconnect(); |
372 transport_.reset(); | 387 transport_.reset(); |
373 } | 388 } |
374 | 389 |
375 } // namespace notifier | 390 } // namespace notifier |
OLD | NEW |