| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "net/base/host_resolver.h" | 14 #include "net/base/host_resolver.h" |
| 15 #include "net/base/ssl_config_service.h" | 15 #include "net/base/ssl_config_service.h" |
| 16 #include "net/http/http_response_info.h" | 16 #include "net/http/http_response_info.h" |
| 17 #include "net/proxy/proxy_server.h" | 17 #include "net/proxy/proxy_server.h" |
| 18 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
| 19 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
| 20 #include "net/socket/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
| 21 #include "net/socket/client_socket_pool.h" | 21 #include "net/socket/client_socket_pool.h" |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 class CertVerifier; |
| 25 class ClientSocketFactory; | 26 class ClientSocketFactory; |
| 26 class ConnectJobFactory; | 27 class ConnectJobFactory; |
| 27 class DnsCertProvenanceChecker; | 28 class DnsCertProvenanceChecker; |
| 28 class DnsRRResolver; | 29 class DnsRRResolver; |
| 29 class HostPortPair; | 30 class HostPortPair; |
| 30 class HttpProxyClientSocketPool; | 31 class HttpProxyClientSocketPool; |
| 31 class HttpProxySocketParams; | 32 class HttpProxySocketParams; |
| 32 class SOCKSClientSocketPool; | 33 class SOCKSClientSocketPool; |
| 33 class SOCKSSocketParams; | 34 class SOCKSSocketParams; |
| 34 class SSLClientSocket; | 35 class SSLClientSocket; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 public: | 89 public: |
| 89 SSLConnectJob( | 90 SSLConnectJob( |
| 90 const std::string& group_name, | 91 const std::string& group_name, |
| 91 const scoped_refptr<SSLSocketParams>& params, | 92 const scoped_refptr<SSLSocketParams>& params, |
| 92 const base::TimeDelta& timeout_duration, | 93 const base::TimeDelta& timeout_duration, |
| 93 TCPClientSocketPool* tcp_pool, | 94 TCPClientSocketPool* tcp_pool, |
| 94 SOCKSClientSocketPool* socks_pool, | 95 SOCKSClientSocketPool* socks_pool, |
| 95 HttpProxyClientSocketPool* http_proxy_pool, | 96 HttpProxyClientSocketPool* http_proxy_pool, |
| 96 ClientSocketFactory* client_socket_factory, | 97 ClientSocketFactory* client_socket_factory, |
| 97 HostResolver* host_resolver, | 98 HostResolver* host_resolver, |
| 99 CertVerifier* cert_verifier, |
| 98 DnsRRResolver* dnsrr_resolver, | 100 DnsRRResolver* dnsrr_resolver, |
| 99 DnsCertProvenanceChecker* dns_cert_checker, | 101 DnsCertProvenanceChecker* dns_cert_checker, |
| 100 SSLHostInfoFactory* ssl_host_info_factory, | 102 SSLHostInfoFactory* ssl_host_info_factory, |
| 101 Delegate* delegate, | 103 Delegate* delegate, |
| 102 NetLog* net_log); | 104 NetLog* net_log); |
| 103 virtual ~SSLConnectJob(); | 105 virtual ~SSLConnectJob(); |
| 104 | 106 |
| 105 // ConnectJob methods. | 107 // ConnectJob methods. |
| 106 virtual LoadState GetLoadState() const; | 108 virtual LoadState GetLoadState() const; |
| 107 | 109 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 137 int DoTunnelConnect(); | 139 int DoTunnelConnect(); |
| 138 int DoTunnelConnectComplete(int result); | 140 int DoTunnelConnectComplete(int result); |
| 139 int DoSSLConnect(); | 141 int DoSSLConnect(); |
| 140 int DoSSLConnectComplete(int result); | 142 int DoSSLConnectComplete(int result); |
| 141 | 143 |
| 142 scoped_refptr<SSLSocketParams> params_; | 144 scoped_refptr<SSLSocketParams> params_; |
| 143 TCPClientSocketPool* const tcp_pool_; | 145 TCPClientSocketPool* const tcp_pool_; |
| 144 SOCKSClientSocketPool* const socks_pool_; | 146 SOCKSClientSocketPool* const socks_pool_; |
| 145 HttpProxyClientSocketPool* const http_proxy_pool_; | 147 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 146 ClientSocketFactory* const client_socket_factory_; | 148 ClientSocketFactory* const client_socket_factory_; |
| 147 HostResolver* const resolver_; | 149 HostResolver* const host_resolver_; |
| 150 CertVerifier* const cert_verifier_; |
| 148 DnsRRResolver* const dnsrr_resolver_; | 151 DnsRRResolver* const dnsrr_resolver_; |
| 149 DnsCertProvenanceChecker* dns_cert_checker_; | 152 DnsCertProvenanceChecker* dns_cert_checker_; |
| 150 SSLHostInfoFactory* const ssl_host_info_factory_; | 153 SSLHostInfoFactory* const ssl_host_info_factory_; |
| 151 | 154 |
| 152 State next_state_; | 155 State next_state_; |
| 153 CompletionCallbackImpl<SSLConnectJob> callback_; | 156 CompletionCallbackImpl<SSLConnectJob> callback_; |
| 154 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 157 scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
| 155 scoped_ptr<SSLClientSocket> ssl_socket_; | 158 scoped_ptr<SSLClientSocket> ssl_socket_; |
| 156 scoped_ptr<SSLHostInfo> ssl_host_info_; | 159 scoped_ptr<SSLHostInfo> ssl_host_info_; |
| 157 | 160 |
| 158 // The time the DoSSLConnect() method was called. | 161 // The time the DoSSLConnect() method was called. |
| 159 base::TimeTicks ssl_connect_start_time_; | 162 base::TimeTicks ssl_connect_start_time_; |
| 160 | 163 |
| 161 HttpResponseInfo error_response_info_; | 164 HttpResponseInfo error_response_info_; |
| 162 | 165 |
| 163 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); | 166 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); |
| 164 }; | 167 }; |
| 165 | 168 |
| 166 class SSLClientSocketPool : public ClientSocketPool, | 169 class SSLClientSocketPool : public ClientSocketPool, |
| 167 public SSLConfigService::Observer { | 170 public SSLConfigService::Observer { |
| 168 public: | 171 public: |
| 169 // Only the pools that will be used are required. i.e. if you never | 172 // Only the pools that will be used are required. i.e. if you never |
| 170 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. | 173 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. |
| 171 SSLClientSocketPool( | 174 SSLClientSocketPool( |
| 172 int max_sockets, | 175 int max_sockets, |
| 173 int max_sockets_per_group, | 176 int max_sockets_per_group, |
| 174 ClientSocketPoolHistograms* histograms, | 177 ClientSocketPoolHistograms* histograms, |
| 175 HostResolver* host_resolver, | 178 HostResolver* host_resolver, |
| 179 CertVerifier* cert_verifier, |
| 176 DnsRRResolver* dnsrr_resolver, | 180 DnsRRResolver* dnsrr_resolver, |
| 177 DnsCertProvenanceChecker* dns_cert_checker, | 181 DnsCertProvenanceChecker* dns_cert_checker, |
| 178 SSLHostInfoFactory* ssl_host_info_factory, | 182 SSLHostInfoFactory* ssl_host_info_factory, |
| 179 ClientSocketFactory* client_socket_factory, | 183 ClientSocketFactory* client_socket_factory, |
| 180 TCPClientSocketPool* tcp_pool, | 184 TCPClientSocketPool* tcp_pool, |
| 181 SOCKSClientSocketPool* socks_pool, | 185 SOCKSClientSocketPool* socks_pool, |
| 182 HttpProxyClientSocketPool* http_proxy_pool, | 186 HttpProxyClientSocketPool* http_proxy_pool, |
| 183 SSLConfigService* ssl_config_service, | 187 SSLConfigService* ssl_config_service, |
| 184 NetLog* net_log); | 188 NetLog* net_log); |
| 185 | 189 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; | 244 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; |
| 241 | 245 |
| 242 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { | 246 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { |
| 243 public: | 247 public: |
| 244 SSLConnectJobFactory( | 248 SSLConnectJobFactory( |
| 245 TCPClientSocketPool* tcp_pool, | 249 TCPClientSocketPool* tcp_pool, |
| 246 SOCKSClientSocketPool* socks_pool, | 250 SOCKSClientSocketPool* socks_pool, |
| 247 HttpProxyClientSocketPool* http_proxy_pool, | 251 HttpProxyClientSocketPool* http_proxy_pool, |
| 248 ClientSocketFactory* client_socket_factory, | 252 ClientSocketFactory* client_socket_factory, |
| 249 HostResolver* host_resolver, | 253 HostResolver* host_resolver, |
| 254 CertVerifier* cert_verifier, |
| 250 DnsRRResolver* dnsrr_resolver, | 255 DnsRRResolver* dnsrr_resolver, |
| 251 DnsCertProvenanceChecker* dns_cert_checker, | 256 DnsCertProvenanceChecker* dns_cert_checker, |
| 252 SSLHostInfoFactory* ssl_host_info_factory, | 257 SSLHostInfoFactory* ssl_host_info_factory, |
| 253 NetLog* net_log); | 258 NetLog* net_log); |
| 254 | 259 |
| 255 virtual ~SSLConnectJobFactory() {} | 260 virtual ~SSLConnectJobFactory() {} |
| 256 | 261 |
| 257 // ClientSocketPoolBase::ConnectJobFactory methods. | 262 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 258 virtual ConnectJob* NewConnectJob( | 263 virtual ConnectJob* NewConnectJob( |
| 259 const std::string& group_name, | 264 const std::string& group_name, |
| 260 const PoolBase::Request& request, | 265 const PoolBase::Request& request, |
| 261 ConnectJob::Delegate* delegate) const; | 266 ConnectJob::Delegate* delegate) const; |
| 262 | 267 |
| 263 virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } | 268 virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } |
| 264 | 269 |
| 265 private: | 270 private: |
| 266 TCPClientSocketPool* const tcp_pool_; | 271 TCPClientSocketPool* const tcp_pool_; |
| 267 SOCKSClientSocketPool* const socks_pool_; | 272 SOCKSClientSocketPool* const socks_pool_; |
| 268 HttpProxyClientSocketPool* const http_proxy_pool_; | 273 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 269 ClientSocketFactory* const client_socket_factory_; | 274 ClientSocketFactory* const client_socket_factory_; |
| 270 HostResolver* const host_resolver_; | 275 HostResolver* const host_resolver_; |
| 276 CertVerifier* const cert_verifier_; |
| 271 DnsRRResolver* const dnsrr_resolver_; | 277 DnsRRResolver* const dnsrr_resolver_; |
| 272 DnsCertProvenanceChecker* const dns_cert_checker_; | 278 DnsCertProvenanceChecker* const dns_cert_checker_; |
| 273 SSLHostInfoFactory* const ssl_host_info_factory_; | 279 SSLHostInfoFactory* const ssl_host_info_factory_; |
| 274 base::TimeDelta timeout_; | 280 base::TimeDelta timeout_; |
| 275 NetLog* net_log_; | 281 NetLog* net_log_; |
| 276 | 282 |
| 277 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); | 283 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); |
| 278 }; | 284 }; |
| 279 | 285 |
| 280 TCPClientSocketPool* const tcp_pool_; | 286 TCPClientSocketPool* const tcp_pool_; |
| 281 SOCKSClientSocketPool* const socks_pool_; | 287 SOCKSClientSocketPool* const socks_pool_; |
| 282 HttpProxyClientSocketPool* const http_proxy_pool_; | 288 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 283 PoolBase base_; | 289 PoolBase base_; |
| 284 const scoped_refptr<SSLConfigService> ssl_config_service_; | 290 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 285 | 291 |
| 286 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 292 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
| 287 }; | 293 }; |
| 288 | 294 |
| 289 REGISTER_SOCKET_PARAMS_FOR_POOL(SSLClientSocketPool, SSLSocketParams); | 295 REGISTER_SOCKET_PARAMS_FOR_POOL(SSLClientSocketPool, SSLSocketParams); |
| 290 | 296 |
| 291 } // namespace net | 297 } // namespace net |
| 292 | 298 |
| 293 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 299 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |