| 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 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 9 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| 10 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 10 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| 11 #pragma once | 11 #pragma once |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/stl_util-inl.h" | 17 #include "base/stl_util-inl.h" |
| 18 #include "base/template_util.h" | 18 #include "base/template_util.h" |
| 19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
| 20 #include "net/base/cert_database.h" | 20 #include "net/base/cert_database.h" |
| 21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 22 #include "net/base/net_api.h" | 22 #include "net/base/net_api.h" |
| 23 #include "net/base/request_priority.h" |
| 23 #include "net/socket/client_socket_pool_histograms.h" | 24 #include "net/socket/client_socket_pool_histograms.h" |
| 24 | 25 |
| 26 class GURL; |
| 25 class Value; | 27 class Value; |
| 26 | 28 |
| 27 namespace net { | 29 namespace net { |
| 28 | 30 |
| 29 class BoundNetLog; | 31 class BoundNetLog; |
| 30 class CertVerifier; | 32 class CertVerifier; |
| 31 class ClientSocketFactory; | 33 class ClientSocketFactory; |
| 32 class ClientSocketHandle; | 34 class ClientSocketHandle; |
| 33 class ClientSocketPoolHistograms; | 35 class ClientSocketPoolHistograms; |
| 34 class DnsCertProvenanceChecker; | 36 class DnsCertProvenanceChecker; |
| 35 class DnsRRResolver; | 37 class DnsRRResolver; |
| 36 class HttpNetworkSession; | 38 class HttpNetworkSession; |
| 39 class HttpRequestHeaders; |
| 37 class HostPortPair; | 40 class HostPortPair; |
| 38 class HttpProxyClientSocketPool; | 41 class HttpProxyClientSocketPool; |
| 39 class HostResolver; | 42 class HostResolver; |
| 40 class NetLog; | 43 class NetLog; |
| 41 class ProxyInfo; | 44 class ProxyInfo; |
| 42 class ProxyService; | 45 class ProxyService; |
| 43 class SOCKSClientSocketPool; | 46 class SOCKSClientSocketPool; |
| 44 class SSLClientSocketPool; | 47 class SSLClientSocketPool; |
| 45 class SSLConfigService; | 48 class SSLConfigService; |
| 46 class SSLHostInfoFactory; | 49 class SSLHostInfoFactory; |
| 47 class TransportClientSocketPool; | 50 class TransportClientSocketPool; |
| 48 | 51 |
| 49 struct HttpRequestInfo; | |
| 50 struct SSLConfig; | 52 struct SSLConfig; |
| 51 | 53 |
| 52 namespace internal { | 54 namespace internal { |
| 53 | 55 |
| 54 // A helper class for auto-deleting Values in the destructor. | 56 // A helper class for auto-deleting Values in the destructor. |
| 55 template <typename Key, typename Value> | 57 template <typename Key, typename Value> |
| 56 class OwnedPoolMap : public std::map<Key, Value> { | 58 class OwnedPoolMap : public std::map<Key, Value> { |
| 57 public: | 59 public: |
| 58 OwnedPoolMap() { | 60 OwnedPoolMap() { |
| 59 COMPILE_ASSERT(base::is_pointer<Value>::value, | 61 COMPILE_ASSERT(base::is_pointer<Value>::value, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 103 |
| 102 static int max_sockets_per_group(); | 104 static int max_sockets_per_group(); |
| 103 NET_API static void set_max_sockets_per_group(int socket_count); | 105 NET_API static void set_max_sockets_per_group(int socket_count); |
| 104 NET_API static void set_max_sockets_per_proxy_server(int socket_count); | 106 NET_API static void set_max_sockets_per_proxy_server(int socket_count); |
| 105 | 107 |
| 106 // A helper method that uses the passed in proxy information to initialize a | 108 // A helper method that uses the passed in proxy information to initialize a |
| 107 // ClientSocketHandle with the relevant socket pool. Use this method for | 109 // ClientSocketHandle with the relevant socket pool. Use this method for |
| 108 // HTTP/HTTPS requests. |ssl_config_for_origin| is only used if the request | 110 // HTTP/HTTPS requests. |ssl_config_for_origin| is only used if the request |
| 109 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. | 111 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. |
| 110 static int InitSocketHandleForHttpRequest( | 112 static int InitSocketHandleForHttpRequest( |
| 111 const HttpRequestInfo& request_info, | 113 const GURL& request_url, |
| 114 const GURL& request_referrer, |
| 115 const HttpRequestHeaders& request_extra_headers, |
| 116 int request_load_flags, |
| 117 RequestPriority request_priority, |
| 112 HttpNetworkSession* session, | 118 HttpNetworkSession* session, |
| 113 const ProxyInfo& proxy_info, | 119 const ProxyInfo& proxy_info, |
| 114 bool force_spdy_over_ssl, | 120 bool force_spdy_over_ssl, |
| 115 bool want_spdy_over_npn, | 121 bool want_spdy_over_npn, |
| 116 const SSLConfig& ssl_config_for_origin, | 122 const SSLConfig& ssl_config_for_origin, |
| 117 const SSLConfig& ssl_config_for_proxy, | 123 const SSLConfig& ssl_config_for_proxy, |
| 118 const BoundNetLog& net_log, | 124 const BoundNetLog& net_log, |
| 119 ClientSocketHandle* socket_handle, | 125 ClientSocketHandle* socket_handle, |
| 120 CompletionCallback* callback); | 126 CompletionCallback* callback); |
| 121 | 127 |
| 122 // A helper method that uses the passed in proxy information to initialize a | 128 // A helper method that uses the passed in proxy information to initialize a |
| 123 // ClientSocketHandle with the relevant socket pool. Use this method for | 129 // ClientSocketHandle with the relevant socket pool. Use this method for |
| 124 // a raw socket connection to a host-port pair (that needs to tunnel through | 130 // a raw socket connection to a host-port pair (that needs to tunnel through |
| 125 // the proxies). | 131 // the proxies). |
| 126 NET_API static int InitSocketHandleForRawConnect( | 132 NET_API static int InitSocketHandleForRawConnect( |
| 127 const HostPortPair& host_port_pair, | 133 const HostPortPair& host_port_pair, |
| 128 HttpNetworkSession* session, | 134 HttpNetworkSession* session, |
| 129 const ProxyInfo& proxy_info, | 135 const ProxyInfo& proxy_info, |
| 130 const SSLConfig& ssl_config_for_origin, | 136 const SSLConfig& ssl_config_for_origin, |
| 131 const SSLConfig& ssl_config_for_proxy, | 137 const SSLConfig& ssl_config_for_proxy, |
| 132 const BoundNetLog& net_log, | 138 const BoundNetLog& net_log, |
| 133 ClientSocketHandle* socket_handle, | 139 ClientSocketHandle* socket_handle, |
| 134 CompletionCallback* callback); | 140 CompletionCallback* callback); |
| 135 | 141 |
| 136 // Similar to InitSocketHandleForHttpRequest except that it initiates the | 142 // Similar to InitSocketHandleForHttpRequest except that it initiates the |
| 137 // desired number of preconnect streams from the relevant socket pool. | 143 // desired number of preconnect streams from the relevant socket pool. |
| 138 static int PreconnectSocketsForHttpRequest( | 144 static int PreconnectSocketsForHttpRequest( |
| 139 const HttpRequestInfo& request_info, | 145 const GURL& request_url, |
| 146 const GURL& request_referrer, |
| 147 const HttpRequestHeaders& request_extra_headers, |
| 148 int request_load_flags, |
| 149 RequestPriority request_priority, |
| 140 HttpNetworkSession* session, | 150 HttpNetworkSession* session, |
| 141 const ProxyInfo& proxy_info, | 151 const ProxyInfo& proxy_info, |
| 142 bool force_spdy_over_ssl, | 152 bool force_spdy_over_ssl, |
| 143 bool want_spdy_over_npn, | 153 bool want_spdy_over_npn, |
| 144 const SSLConfig& ssl_config_for_origin, | 154 const SSLConfig& ssl_config_for_origin, |
| 145 const SSLConfig& ssl_config_for_proxy, | 155 const SSLConfig& ssl_config_for_proxy, |
| 146 const BoundNetLog& net_log, | 156 const BoundNetLog& net_log, |
| 147 int num_preconnect_streams); | 157 int num_preconnect_streams); |
| 148 | 158 |
| 149 // Creates a Value summary of the state of the socket pools. The caller is | 159 // Creates a Value summary of the state of the socket pools. The caller is |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 214 |
| 205 ClientSocketPoolHistograms ssl_socket_pool_for_proxies_histograms_; | 215 ClientSocketPoolHistograms ssl_socket_pool_for_proxies_histograms_; |
| 206 SSLSocketPoolMap ssl_socket_pools_for_proxies_; | 216 SSLSocketPoolMap ssl_socket_pools_for_proxies_; |
| 207 | 217 |
| 208 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolManager); | 218 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolManager); |
| 209 }; | 219 }; |
| 210 | 220 |
| 211 } // namespace net | 221 } // namespace net |
| 212 | 222 |
| 213 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 223 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| OLD | NEW |