| 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 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a | 5 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a |
| 6 // simple container for all of them. Most importantly, it handles the lifetime | 6 // simple container for all of them. Most importantly, it handles the lifetime |
| 7 // and destruction order properly. | 7 // and destruction order properly. |
| 8 | 8 |
| 9 #include "net/socket/client_socket_pool_manager.h" | 9 #include "net/socket/client_socket_pool_manager.h" |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // The meat of the implementation for the InitSocketHandleForHttpRequest, | 59 // The meat of the implementation for the InitSocketHandleForHttpRequest, |
| 60 // InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods. | 60 // InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods. |
| 61 int InitSocketPoolHelper(const HttpRequestInfo& request_info, | 61 int InitSocketPoolHelper(const HttpRequestInfo& request_info, |
| 62 HttpNetworkSession* session, | 62 HttpNetworkSession* session, |
| 63 const ProxyInfo& proxy_info, | 63 const ProxyInfo& proxy_info, |
| 64 bool force_spdy_over_ssl, | 64 bool force_spdy_over_ssl, |
| 65 bool want_spdy_over_npn, | 65 bool want_spdy_over_npn, |
| 66 const SSLConfig& ssl_config_for_origin, | 66 const SSLConfig& ssl_config_for_origin, |
| 67 const SSLConfig& ssl_config_for_proxy, | 67 const SSLConfig& ssl_config_for_proxy, |
| 68 bool force_tunnel, |
| 68 const BoundNetLog& net_log, | 69 const BoundNetLog& net_log, |
| 69 int num_preconnect_streams, | 70 int num_preconnect_streams, |
| 70 ClientSocketHandle* socket_handle, | 71 ClientSocketHandle* socket_handle, |
| 71 CompletionCallback* callback) { | 72 CompletionCallback* callback) { |
| 72 scoped_refptr<TransportSocketParams> tcp_params; | 73 scoped_refptr<TransportSocketParams> tcp_params; |
| 73 scoped_refptr<HttpProxySocketParams> http_proxy_params; | 74 scoped_refptr<HttpProxySocketParams> http_proxy_params; |
| 74 scoped_refptr<SOCKSSocketParams> socks_params; | 75 scoped_refptr<SOCKSSocketParams> socks_params; |
| 75 scoped_ptr<HostPortPair> proxy_host_port; | 76 scoped_ptr<HostPortPair> proxy_host_port; |
| 76 | 77 |
| 77 bool using_ssl = request_info.url.SchemeIs("https") || force_spdy_over_ssl; | 78 bool using_ssl = request_info.url.SchemeIs("https") || force_spdy_over_ssl; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 135 |
| 135 http_proxy_params = | 136 http_proxy_params = |
| 136 new HttpProxySocketParams(proxy_tcp_params, | 137 new HttpProxySocketParams(proxy_tcp_params, |
| 137 ssl_params, | 138 ssl_params, |
| 138 request_info.url, | 139 request_info.url, |
| 139 user_agent, | 140 user_agent, |
| 140 origin_host_port, | 141 origin_host_port, |
| 141 session->http_auth_cache(), | 142 session->http_auth_cache(), |
| 142 session->http_auth_handler_factory(), | 143 session->http_auth_handler_factory(), |
| 143 session->spdy_session_pool(), | 144 session->spdy_session_pool(), |
| 144 using_ssl); | 145 force_tunnel || using_ssl); |
| 145 } else { | 146 } else { |
| 146 DCHECK(proxy_info.is_socks()); | 147 DCHECK(proxy_info.is_socks()); |
| 147 char socks_version; | 148 char socks_version; |
| 148 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) | 149 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) |
| 149 socks_version = '5'; | 150 socks_version = '5'; |
| 150 else | 151 else |
| 151 socks_version = '4'; | 152 socks_version = '4'; |
| 152 connection_group = base::StringPrintf( | 153 connection_group = base::StringPrintf( |
| 153 "socks%c/%s", socks_version, connection_group.c_str()); | 154 "socks%c/%s", socks_version, connection_group.c_str()); |
| 154 | 155 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 ClientSocketHandle* socket_handle, | 612 ClientSocketHandle* socket_handle, |
| 612 CompletionCallback* callback) { | 613 CompletionCallback* callback) { |
| 613 DCHECK(socket_handle); | 614 DCHECK(socket_handle); |
| 614 return InitSocketPoolHelper(request_info, | 615 return InitSocketPoolHelper(request_info, |
| 615 session, | 616 session, |
| 616 proxy_info, | 617 proxy_info, |
| 617 force_spdy_over_ssl, | 618 force_spdy_over_ssl, |
| 618 want_spdy_over_npn, | 619 want_spdy_over_npn, |
| 619 ssl_config_for_origin, | 620 ssl_config_for_origin, |
| 620 ssl_config_for_proxy, | 621 ssl_config_for_proxy, |
| 622 false, |
| 621 net_log, | 623 net_log, |
| 622 0, | 624 0, |
| 623 socket_handle, | 625 socket_handle, |
| 624 callback); | 626 callback); |
| 625 } | 627 } |
| 626 | 628 |
| 627 // static | 629 // static |
| 628 int ClientSocketPoolManager::InitSocketHandleForRawConnect( | 630 int ClientSocketPoolManager::InitSocketHandleForRawConnect( |
| 629 const HostPortPair& host_port_pair, | 631 const HostPortPair& host_port_pair, |
| 630 HttpNetworkSession* session, | 632 HttpNetworkSession* session, |
| 631 const ProxyInfo& proxy_info, | 633 const ProxyInfo& proxy_info, |
| 632 const SSLConfig& ssl_config_for_origin, | 634 const SSLConfig& ssl_config_for_origin, |
| 633 const SSLConfig& ssl_config_for_proxy, | 635 const SSLConfig& ssl_config_for_proxy, |
| 634 const BoundNetLog& net_log, | 636 const BoundNetLog& net_log, |
| 635 ClientSocketHandle* socket_handle, | 637 ClientSocketHandle* socket_handle, |
| 636 CompletionCallback* callback) { | 638 CompletionCallback* callback) { |
| 637 DCHECK(socket_handle); | 639 DCHECK(socket_handle); |
| 638 // Synthesize an HttpRequestInfo. | 640 // Synthesize an HttpRequestInfo. |
| 639 HttpRequestInfo request_info; | 641 HttpRequestInfo request_info; |
| 640 request_info.url = GURL("http://" + host_port_pair.ToString()); | 642 request_info.url = GURL("http://" + host_port_pair.ToString()); |
| 641 return InitSocketPoolHelper(request_info, | 643 return InitSocketPoolHelper(request_info, |
| 642 session, | 644 session, |
| 643 proxy_info, | 645 proxy_info, |
| 644 false, | 646 false, |
| 645 false, | 647 false, |
| 646 ssl_config_for_origin, | 648 ssl_config_for_origin, |
| 647 ssl_config_for_proxy, | 649 ssl_config_for_proxy, |
| 650 true, |
| 648 net_log, | 651 net_log, |
| 649 0, | 652 0, |
| 650 socket_handle, | 653 socket_handle, |
| 651 callback); | 654 callback); |
| 652 } | 655 } |
| 653 | 656 |
| 654 // static | 657 // static |
| 655 int ClientSocketPoolManager::PreconnectSocketsForHttpRequest( | 658 int ClientSocketPoolManager::PreconnectSocketsForHttpRequest( |
| 656 const HttpRequestInfo& request_info, | 659 const HttpRequestInfo& request_info, |
| 657 HttpNetworkSession* session, | 660 HttpNetworkSession* session, |
| 658 const ProxyInfo& proxy_info, | 661 const ProxyInfo& proxy_info, |
| 659 bool force_spdy_over_ssl, | 662 bool force_spdy_over_ssl, |
| 660 bool want_spdy_over_npn, | 663 bool want_spdy_over_npn, |
| 661 const SSLConfig& ssl_config_for_origin, | 664 const SSLConfig& ssl_config_for_origin, |
| 662 const SSLConfig& ssl_config_for_proxy, | 665 const SSLConfig& ssl_config_for_proxy, |
| 663 const BoundNetLog& net_log, | 666 const BoundNetLog& net_log, |
| 664 int num_preconnect_streams) { | 667 int num_preconnect_streams) { |
| 665 return InitSocketPoolHelper(request_info, | 668 return InitSocketPoolHelper(request_info, |
| 666 session, | 669 session, |
| 667 proxy_info, | 670 proxy_info, |
| 668 force_spdy_over_ssl, | 671 force_spdy_over_ssl, |
| 669 want_spdy_over_npn, | 672 want_spdy_over_npn, |
| 670 ssl_config_for_origin, | 673 ssl_config_for_origin, |
| 671 ssl_config_for_proxy, | 674 ssl_config_for_proxy, |
| 675 false, |
| 672 net_log, | 676 net_log, |
| 673 num_preconnect_streams, | 677 num_preconnect_streams, |
| 674 NULL, | 678 NULL, |
| 675 NULL); | 679 NULL); |
| 676 } | 680 } |
| 677 | 681 |
| 678 | 682 |
| 679 } // namespace net | 683 } // namespace net |
| OLD | NEW |