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 #include "jingle/glue/proxy_resolving_client_socket.h" | 5 #include "jingle/glue/proxy_resolving_client_socket.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
16 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
17 #include "net/base/load_flags.h" | |
18 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
19 #include "net/http/http_auth_controller.h" | 18 #include "net/http/http_auth_controller.h" |
20 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
21 #include "net/http/proxy_client_socket.h" | 20 #include "net/http/proxy_client_socket.h" |
22 #include "net/socket/client_socket_handle.h" | 21 #include "net/socket/client_socket_handle.h" |
23 #include "net/socket/client_socket_pool_manager.h" | 22 #include "net/socket/client_socket_pool_manager.h" |
24 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
25 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
26 | 25 |
27 namespace jingle_glue { | 26 namespace jingle_glue { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int ProxyResolvingClientSocket::Connect( | 136 int ProxyResolvingClientSocket::Connect( |
138 const net::CompletionCallback& callback) { | 137 const net::CompletionCallback& callback) { |
139 DCHECK(user_connect_callback_.is_null()); | 138 DCHECK(user_connect_callback_.is_null()); |
140 | 139 |
141 tried_direct_connect_fallback_ = false; | 140 tried_direct_connect_fallback_ = false; |
142 | 141 |
143 // First we try and resolve the proxy. | 142 // First we try and resolve the proxy. |
144 int status = network_session_->proxy_service()->ResolveProxy( | 143 int status = network_session_->proxy_service()->ResolveProxy( |
145 proxy_url_, | 144 proxy_url_, |
146 std::string(), | 145 std::string(), |
147 net::LOAD_NORMAL, | |
148 &proxy_info_, | 146 &proxy_info_, |
149 proxy_resolve_callback_, | 147 proxy_resolve_callback_, |
150 &pac_request_, | 148 &pac_request_, |
151 NULL, | 149 NULL, |
152 bound_net_log_); | 150 bound_net_log_); |
153 if (status != net::ERR_IO_PENDING) { | 151 if (status != net::ERR_IO_PENDING) { |
154 // We defer execution of ProcessProxyResolveDone instead of calling it | 152 // We defer execution of ProcessProxyResolveDone instead of calling it |
155 // directly here for simplicity. From the caller's point of view, | 153 // directly here for simplicity. From the caller's point of view, |
156 // the connect always happens asynchronously. | 154 // the connect always happens asynchronously. |
157 base::ThreadTaskRunnerHandle::Get()->PostTask( | 155 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 default: | 284 default: |
287 return error; | 285 return error; |
288 } | 286 } |
289 | 287 |
290 if (proxy_info_.is_https() && ssl_config_.send_client_cert) { | 288 if (proxy_info_.is_https() && ssl_config_.send_client_cert) { |
291 network_session_->ssl_client_auth_cache()->Remove( | 289 network_session_->ssl_client_auth_cache()->Remove( |
292 proxy_info_.proxy_server().host_port_pair()); | 290 proxy_info_.proxy_server().host_port_pair()); |
293 } | 291 } |
294 | 292 |
295 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( | 293 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( |
296 proxy_url_, std::string(), net::LOAD_NORMAL, error, &proxy_info_, | 294 proxy_url_, std::string(), error, &proxy_info_, proxy_resolve_callback_, |
297 proxy_resolve_callback_, &pac_request_, NULL, bound_net_log_); | 295 &pac_request_, NULL, bound_net_log_); |
298 if (rv == net::OK || rv == net::ERR_IO_PENDING) { | 296 if (rv == net::OK || rv == net::ERR_IO_PENDING) { |
299 CloseTransportSocket(); | 297 CloseTransportSocket(); |
300 } else { | 298 } else { |
301 // If ReconsiderProxyAfterError() failed synchronously, it means | 299 // If ReconsiderProxyAfterError() failed synchronously, it means |
302 // there was nothing left to fall-back to, so fail the transaction | 300 // there was nothing left to fall-back to, so fail the transaction |
303 // with the last connection error we got. | 301 // with the last connection error we got. |
304 rv = error; | 302 rv = error; |
305 } | 303 } |
306 | 304 |
307 // We either have new proxy info or there was an error in falling back. | 305 // We either have new proxy info or there was an error in falling back. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 return 0; | 423 return 0; |
426 } | 424 } |
427 | 425 |
428 void ProxyResolvingClientSocket::CloseTransportSocket() { | 426 void ProxyResolvingClientSocket::CloseTransportSocket() { |
429 if (transport_.get() && transport_->socket()) | 427 if (transport_.get() && transport_->socket()) |
430 transport_->socket()->Disconnect(); | 428 transport_->socket()->Disconnect(); |
431 transport_.reset(); | 429 transport_.reset(); |
432 } | 430 } |
433 | 431 |
434 } // namespace jingle_glue | 432 } // namespace jingle_glue |
OLD | NEW |