| 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/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/http/http_auth_controller.h" | 18 #include "net/http/http_auth_controller.h" |
| 19 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
| 20 #include "net/http/proxy_client_socket.h" | 20 #include "net/http/proxy_client_socket.h" |
| 21 #include "net/log/net_log_source_type.h" |
| 21 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
| 22 #include "net/socket/client_socket_pool_manager.h" | 23 #include "net/socket/client_socket_pool_manager.h" |
| 23 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 25 | 26 |
| 26 namespace jingle_glue { | 27 namespace jingle_glue { |
| 27 | 28 |
| 28 ProxyResolvingClientSocket::ProxyResolvingClientSocket( | 29 ProxyResolvingClientSocket::ProxyResolvingClientSocket( |
| 29 net::ClientSocketFactory* socket_factory, | 30 net::ClientSocketFactory* socket_factory, |
| 30 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 31 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 31 const net::SSLConfig& ssl_config, | 32 const net::SSLConfig& ssl_config, |
| 32 const net::HostPortPair& dest_host_port_pair) | 33 const net::HostPortPair& dest_host_port_pair) |
| 33 : proxy_resolve_callback_( | 34 : proxy_resolve_callback_( |
| 34 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, | 35 base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone, |
| 35 base::Unretained(this))), | 36 base::Unretained(this))), |
| 36 connect_callback_( | 37 connect_callback_( |
| 37 base::Bind(&ProxyResolvingClientSocket::ProcessConnectDone, | 38 base::Bind(&ProxyResolvingClientSocket::ProcessConnectDone, |
| 38 base::Unretained(this))), | 39 base::Unretained(this))), |
| 39 ssl_config_(ssl_config), | 40 ssl_config_(ssl_config), |
| 40 pac_request_(NULL), | 41 pac_request_(NULL), |
| 41 dest_host_port_pair_(dest_host_port_pair), | 42 dest_host_port_pair_(dest_host_port_pair), |
| 42 // Assume that we intend to do TLS on this socket; all | 43 // Assume that we intend to do TLS on this socket; all |
| 43 // current use cases do. | 44 // current use cases do. |
| 44 proxy_url_("https://" + dest_host_port_pair_.ToString()), | 45 proxy_url_("https://" + dest_host_port_pair_.ToString()), |
| 45 tried_direct_connect_fallback_(false), | 46 tried_direct_connect_fallback_(false), |
| 46 bound_net_log_( | 47 bound_net_log_( |
| 47 net::BoundNetLog::Make( | 48 net::BoundNetLog::Make( |
| 48 request_context_getter->GetURLRequestContext()->net_log(), | 49 request_context_getter->GetURLRequestContext()->net_log(), |
| 49 net::NetLog::SOURCE_SOCKET)), | 50 net::NetLogSourceType::SOCKET)), |
| 50 weak_factory_(this) { | 51 weak_factory_(this) { |
| 51 DCHECK(request_context_getter.get()); | 52 DCHECK(request_context_getter.get()); |
| 52 net::URLRequestContext* request_context = | 53 net::URLRequestContext* request_context = |
| 53 request_context_getter->GetURLRequestContext(); | 54 request_context_getter->GetURLRequestContext(); |
| 54 DCHECK(request_context); | 55 DCHECK(request_context); |
| 55 DCHECK(!dest_host_port_pair_.host().empty()); | 56 DCHECK(!dest_host_port_pair_.host().empty()); |
| 56 DCHECK_GT(dest_host_port_pair_.port(), 0); | 57 DCHECK_GT(dest_host_port_pair_.port(), 0); |
| 57 DCHECK(proxy_url_.is_valid()); | 58 DCHECK(proxy_url_.is_valid()); |
| 58 | 59 |
| 59 net::HttpNetworkSession::Params session_params; | 60 net::HttpNetworkSession::Params session_params; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 return 0; | 424 return 0; |
| 424 } | 425 } |
| 425 | 426 |
| 426 void ProxyResolvingClientSocket::CloseTransportSocket() { | 427 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 427 if (transport_.get() && transport_->socket()) | 428 if (transport_.get() && transport_->socket()) |
| 428 transport_->socket()->Disconnect(); | 429 transport_->socket()->Disconnect(); |
| 429 transport_.reset(); | 430 transport_.reset(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 } // namespace jingle_glue | 433 } // namespace jingle_glue |
| OLD | NEW |