| 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 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/http/http_auth_controller.h" | 17 #include "net/http/http_auth_controller.h" |
| 17 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 133 |
| 133 int ProxyResolvingClientSocket::Connect( | 134 int ProxyResolvingClientSocket::Connect( |
| 134 const net::CompletionCallback& callback) { | 135 const net::CompletionCallback& callback) { |
| 135 DCHECK(user_connect_callback_.is_null()); | 136 DCHECK(user_connect_callback_.is_null()); |
| 136 | 137 |
| 137 tried_direct_connect_fallback_ = false; | 138 tried_direct_connect_fallback_ = false; |
| 138 | 139 |
| 139 // First we try and resolve the proxy. | 140 // First we try and resolve the proxy. |
| 140 int status = network_session_->proxy_service()->ResolveProxy( | 141 int status = network_session_->proxy_service()->ResolveProxy( |
| 141 proxy_url_, | 142 proxy_url_, |
| 143 std::string(), |
| 142 net::LOAD_NORMAL, | 144 net::LOAD_NORMAL, |
| 143 &proxy_info_, | 145 &proxy_info_, |
| 144 proxy_resolve_callback_, | 146 proxy_resolve_callback_, |
| 145 &pac_request_, | 147 &pac_request_, |
| 146 NULL, | 148 NULL, |
| 147 bound_net_log_); | 149 bound_net_log_); |
| 148 if (status != net::ERR_IO_PENDING) { | 150 if (status != net::ERR_IO_PENDING) { |
| 149 // We defer execution of ProcessProxyResolveDone instead of calling it | 151 // We defer execution of ProcessProxyResolveDone instead of calling it |
| 150 // directly here for simplicity. From the caller's point of view, | 152 // directly here for simplicity. From the caller's point of view, |
| 151 // the connect always happens asynchronously. | 153 // the connect always happens asynchronously. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 default: | 285 default: |
| 284 return error; | 286 return error; |
| 285 } | 287 } |
| 286 | 288 |
| 287 if (proxy_info_.is_https() && ssl_config_.send_client_cert) { | 289 if (proxy_info_.is_https() && ssl_config_.send_client_cert) { |
| 288 network_session_->ssl_client_auth_cache()->Remove( | 290 network_session_->ssl_client_auth_cache()->Remove( |
| 289 proxy_info_.proxy_server().host_port_pair()); | 291 proxy_info_.proxy_server().host_port_pair()); |
| 290 } | 292 } |
| 291 | 293 |
| 292 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( | 294 int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( |
| 293 proxy_url_, net::LOAD_NORMAL, error, &proxy_info_, | 295 proxy_url_, std::string(), net::LOAD_NORMAL, error, &proxy_info_, |
| 294 proxy_resolve_callback_, &pac_request_, NULL, bound_net_log_); | 296 proxy_resolve_callback_, &pac_request_, NULL, bound_net_log_); |
| 295 if (rv == net::OK || rv == net::ERR_IO_PENDING) { | 297 if (rv == net::OK || rv == net::ERR_IO_PENDING) { |
| 296 CloseTransportSocket(); | 298 CloseTransportSocket(); |
| 297 } else { | 299 } else { |
| 298 // If ReconsiderProxyAfterError() failed synchronously, it means | 300 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 299 // there was nothing left to fall-back to, so fail the transaction | 301 // there was nothing left to fall-back to, so fail the transaction |
| 300 // with the last connection error we got. | 302 // with the last connection error we got. |
| 301 rv = error; | 303 rv = error; |
| 302 } | 304 } |
| 303 | 305 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return 0; | 433 return 0; |
| 432 } | 434 } |
| 433 | 435 |
| 434 void ProxyResolvingClientSocket::CloseTransportSocket() { | 436 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 435 if (transport_.get() && transport_->socket()) | 437 if (transport_.get() && transport_->socket()) |
| 436 transport_->socket()->Disconnect(); | 438 transport_->socket()->Disconnect(); |
| 437 transport_.reset(); | 439 transport_.reset(); |
| 438 } | 440 } |
| 439 | 441 |
| 440 } // namespace jingle_glue | 442 } // namespace jingle_glue |
| OLD | NEW |