| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 ClientSocketHandle* socket_handle, | 598 ClientSocketHandle* socket_handle, |
| 598 CompletionCallback* callback) { | 599 CompletionCallback* callback) { |
| 599 DCHECK(socket_handle); | 600 DCHECK(socket_handle); |
| 600 return InitSocketPoolHelper(request_info, | 601 return InitSocketPoolHelper(request_info, |
| 601 session, | 602 session, |
| 602 proxy_info, | 603 proxy_info, |
| 603 force_spdy_over_ssl, | 604 force_spdy_over_ssl, |
| 604 want_spdy_over_npn, | 605 want_spdy_over_npn, |
| 605 ssl_config_for_origin, | 606 ssl_config_for_origin, |
| 606 ssl_config_for_proxy, | 607 ssl_config_for_proxy, |
| 608 false, |
| 607 net_log, | 609 net_log, |
| 608 0, | 610 0, |
| 609 socket_handle, | 611 socket_handle, |
| 610 callback); | 612 callback); |
| 611 } | 613 } |
| 612 | 614 |
| 613 // static | 615 // static |
| 614 int ClientSocketPoolManager::InitSocketHandleForRawConnect( | 616 int ClientSocketPoolManager::InitSocketHandleForRawConnect( |
| 615 const HostPortPair& host_port_pair, | 617 const HostPortPair& host_port_pair, |
| 616 HttpNetworkSession* session, | 618 HttpNetworkSession* session, |
| 617 const ProxyInfo& proxy_info, | 619 const ProxyInfo& proxy_info, |
| 618 const SSLConfig& ssl_config_for_origin, | 620 const SSLConfig& ssl_config_for_origin, |
| 619 const SSLConfig& ssl_config_for_proxy, | 621 const SSLConfig& ssl_config_for_proxy, |
| 620 const BoundNetLog& net_log, | 622 const BoundNetLog& net_log, |
| 621 ClientSocketHandle* socket_handle, | 623 ClientSocketHandle* socket_handle, |
| 622 CompletionCallback* callback) { | 624 CompletionCallback* callback) { |
| 623 DCHECK(socket_handle); | 625 DCHECK(socket_handle); |
| 624 // Synthesize an HttpRequestInfo. | 626 // Synthesize an HttpRequestInfo. |
| 625 HttpRequestInfo request_info; | 627 HttpRequestInfo request_info; |
| 626 request_info.url = GURL("http://" + host_port_pair.ToString()); | 628 request_info.url = GURL("http://" + host_port_pair.ToString()); |
| 627 return InitSocketPoolHelper(request_info, | 629 return InitSocketPoolHelper(request_info, |
| 628 session, | 630 session, |
| 629 proxy_info, | 631 proxy_info, |
| 630 false, | 632 false, |
| 631 false, | 633 false, |
| 632 ssl_config_for_origin, | 634 ssl_config_for_origin, |
| 633 ssl_config_for_proxy, | 635 ssl_config_for_proxy, |
| 636 true, |
| 634 net_log, | 637 net_log, |
| 635 0, | 638 0, |
| 636 socket_handle, | 639 socket_handle, |
| 637 callback); | 640 callback); |
| 638 } | 641 } |
| 639 | 642 |
| 640 // static | 643 // static |
| 641 int ClientSocketPoolManager::PreconnectSocketsForHttpRequest( | 644 int ClientSocketPoolManager::PreconnectSocketsForHttpRequest( |
| 642 const HttpRequestInfo& request_info, | 645 const HttpRequestInfo& request_info, |
| 643 HttpNetworkSession* session, | 646 HttpNetworkSession* session, |
| 644 const ProxyInfo& proxy_info, | 647 const ProxyInfo& proxy_info, |
| 645 bool force_spdy_over_ssl, | 648 bool force_spdy_over_ssl, |
| 646 bool want_spdy_over_npn, | 649 bool want_spdy_over_npn, |
| 647 const SSLConfig& ssl_config_for_origin, | 650 const SSLConfig& ssl_config_for_origin, |
| 648 const SSLConfig& ssl_config_for_proxy, | 651 const SSLConfig& ssl_config_for_proxy, |
| 649 const BoundNetLog& net_log, | 652 const BoundNetLog& net_log, |
| 650 int num_preconnect_streams) { | 653 int num_preconnect_streams) { |
| 651 return InitSocketPoolHelper(request_info, | 654 return InitSocketPoolHelper(request_info, |
| 652 session, | 655 session, |
| 653 proxy_info, | 656 proxy_info, |
| 654 force_spdy_over_ssl, | 657 force_spdy_over_ssl, |
| 655 want_spdy_over_npn, | 658 want_spdy_over_npn, |
| 656 ssl_config_for_origin, | 659 ssl_config_for_origin, |
| 657 ssl_config_for_proxy, | 660 ssl_config_for_proxy, |
| 661 false, |
| 658 net_log, | 662 net_log, |
| 659 num_preconnect_streams, | 663 num_preconnect_streams, |
| 660 NULL, | 664 NULL, |
| 661 NULL); | 665 NULL); |
| 662 } | 666 } |
| 663 | 667 |
| 664 | 668 |
| 665 } // namespace net | 669 } // namespace net |
| OLD | NEW |