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_(net::BoundNetLog::Make( |
47 net::BoundNetLog::Make( | 48 request_context_getter->GetURLRequestContext()->net_log(), |
48 request_context_getter->GetURLRequestContext()->net_log(), | 49 net::NetLogSourceType::SOCKET)), |
49 net::NetLog::SOURCE_SOCKET)), | 50 weak_factory_(this) { |
50 weak_factory_(this) { | |
51 DCHECK(request_context_getter.get()); | 51 DCHECK(request_context_getter.get()); |
52 net::URLRequestContext* request_context = | 52 net::URLRequestContext* request_context = |
53 request_context_getter->GetURLRequestContext(); | 53 request_context_getter->GetURLRequestContext(); |
54 DCHECK(request_context); | 54 DCHECK(request_context); |
55 DCHECK(!dest_host_port_pair_.host().empty()); | 55 DCHECK(!dest_host_port_pair_.host().empty()); |
56 DCHECK_GT(dest_host_port_pair_.port(), 0); | 56 DCHECK_GT(dest_host_port_pair_.port(), 0); |
57 DCHECK(proxy_url_.is_valid()); | 57 DCHECK(proxy_url_.is_valid()); |
58 | 58 |
59 net::HttpNetworkSession::Params session_params; | 59 net::HttpNetworkSession::Params session_params; |
60 session_params.client_socket_factory = socket_factory; | 60 session_params.client_socket_factory = socket_factory; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return 0; | 423 return 0; |
424 } | 424 } |
425 | 425 |
426 void ProxyResolvingClientSocket::CloseTransportSocket() { | 426 void ProxyResolvingClientSocket::CloseTransportSocket() { |
427 if (transport_.get() && transport_->socket()) | 427 if (transport_.get() && transport_->socket()) |
428 transport_->socket()->Disconnect(); | 428 transport_->socket()->Disconnect(); |
429 transport_.reset(); | 429 transport_.reset(); |
430 } | 430 } |
431 | 431 |
432 } // namespace jingle_glue | 432 } // namespace jingle_glue |
OLD | NEW |