| 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 #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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 class TransportSecurityState; | 35 class TransportSecurityState; |
| 36 class TransportSocketParams; | 36 class TransportSocketParams; |
| 37 | 37 |
| 38 class NET_EXPORT_PRIVATE SSLSocketParams | 38 class NET_EXPORT_PRIVATE SSLSocketParams |
| 39 : public base::RefCounted<SSLSocketParams> { | 39 : public base::RefCounted<SSLSocketParams> { |
| 40 public: | 40 public: |
| 41 enum ConnectionType { DIRECT, SOCKS_PROXY, HTTP_PROXY }; | 41 enum ConnectionType { DIRECT, SOCKS_PROXY, HTTP_PROXY }; |
| 42 | 42 |
| 43 // Exactly one of |direct_params|, |socks_proxy_params|, and | 43 // Exactly one of |direct_params|, |socks_proxy_params|, and |
| 44 // |http_proxy_params| must be non-NULL. | 44 // |http_proxy_params| must be non-NULL. |
| 45 SSLSocketParams( | 45 SSLSocketParams(const scoped_refptr<TransportSocketParams>& direct_params, |
| 46 const scoped_refptr<TransportSocketParams>& direct_params, | 46 const scoped_refptr<SOCKSSocketParams>& socks_proxy_params, |
| 47 const scoped_refptr<SOCKSSocketParams>& socks_proxy_params, | 47 const scoped_refptr<HttpProxySocketParams>& http_proxy_params, |
| 48 const scoped_refptr<HttpProxySocketParams>& http_proxy_params, | 48 const HostPortPair& host_and_port, |
| 49 const HostPortPair& host_and_port, | 49 const SSLConfig& ssl_config, |
| 50 const SSLConfig& ssl_config, | 50 PrivacyMode privacy_mode, |
| 51 PrivacyMode privacy_mode, | 51 int load_flags, |
| 52 int load_flags, | 52 bool force_spdy_over_ssl, |
| 53 bool force_spdy_over_ssl, | 53 bool want_spdy_over_npn); |
| 54 bool want_spdy_over_npn); | |
| 55 | 54 |
| 56 // Returns the type of the underlying connection. | 55 // Returns the type of the underlying connection. |
| 57 ConnectionType GetConnectionType() const; | 56 ConnectionType GetConnectionType() const; |
| 58 | 57 |
| 59 // Must be called only when GetConnectionType() returns DIRECT. | 58 // Must be called only when GetConnectionType() returns DIRECT. |
| 60 const scoped_refptr<TransportSocketParams>& | 59 const scoped_refptr<TransportSocketParams>& GetDirectConnectionParams() const; |
| 61 GetDirectConnectionParams() const; | |
| 62 | 60 |
| 63 // Must be called only when GetConnectionType() returns SOCKS_PROXY. | 61 // Must be called only when GetConnectionType() returns SOCKS_PROXY. |
| 64 const scoped_refptr<SOCKSSocketParams>& | 62 const scoped_refptr<SOCKSSocketParams>& GetSocksProxyConnectionParams() const; |
| 65 GetSocksProxyConnectionParams() const; | |
| 66 | 63 |
| 67 // Must be called only when GetConnectionType() returns HTTP_PROXY. | 64 // Must be called only when GetConnectionType() returns HTTP_PROXY. |
| 68 const scoped_refptr<HttpProxySocketParams>& | 65 const scoped_refptr<HttpProxySocketParams>& GetHttpProxyConnectionParams() |
| 69 GetHttpProxyConnectionParams() const; | 66 const; |
| 70 | 67 |
| 71 const HostPortPair& host_and_port() const { return host_and_port_; } | 68 const HostPortPair& host_and_port() const { return host_and_port_; } |
| 72 const SSLConfig& ssl_config() const { return ssl_config_; } | 69 const SSLConfig& ssl_config() const { return ssl_config_; } |
| 73 PrivacyMode privacy_mode() const { return privacy_mode_; } | 70 PrivacyMode privacy_mode() const { return privacy_mode_; } |
| 74 int load_flags() const { return load_flags_; } | 71 int load_flags() const { return load_flags_; } |
| 75 bool force_spdy_over_ssl() const { return force_spdy_over_ssl_; } | 72 bool force_spdy_over_ssl() const { return force_spdy_over_ssl_; } |
| 76 bool want_spdy_over_npn() const { return want_spdy_over_npn_; } | 73 bool want_spdy_over_npn() const { return want_spdy_over_npn_; } |
| 77 bool ignore_limits() const { return ignore_limits_; } | 74 bool ignore_limits() const { return ignore_limits_; } |
| 78 | 75 |
| 79 private: | 76 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 const bool want_spdy_over_npn_; | 88 const bool want_spdy_over_npn_; |
| 92 bool ignore_limits_; | 89 bool ignore_limits_; |
| 93 | 90 |
| 94 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); | 91 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); |
| 95 }; | 92 }; |
| 96 | 93 |
| 97 // SSLConnectJob handles the SSL handshake after setting up the underlying | 94 // SSLConnectJob handles the SSL handshake after setting up the underlying |
| 98 // connection as specified in the params. | 95 // connection as specified in the params. |
| 99 class SSLConnectJob : public ConnectJob { | 96 class SSLConnectJob : public ConnectJob { |
| 100 public: | 97 public: |
| 101 SSLConnectJob( | 98 SSLConnectJob(const std::string& group_name, |
| 102 const std::string& group_name, | 99 RequestPriority priority, |
| 103 RequestPriority priority, | 100 const scoped_refptr<SSLSocketParams>& params, |
| 104 const scoped_refptr<SSLSocketParams>& params, | 101 const base::TimeDelta& timeout_duration, |
| 105 const base::TimeDelta& timeout_duration, | 102 TransportClientSocketPool* transport_pool, |
| 106 TransportClientSocketPool* transport_pool, | 103 SOCKSClientSocketPool* socks_pool, |
| 107 SOCKSClientSocketPool* socks_pool, | 104 HttpProxyClientSocketPool* http_proxy_pool, |
| 108 HttpProxyClientSocketPool* http_proxy_pool, | 105 ClientSocketFactory* client_socket_factory, |
| 109 ClientSocketFactory* client_socket_factory, | 106 HostResolver* host_resolver, |
| 110 HostResolver* host_resolver, | 107 const SSLClientSocketContext& context, |
| 111 const SSLClientSocketContext& context, | 108 Delegate* delegate, |
| 112 Delegate* delegate, | 109 NetLog* net_log); |
| 113 NetLog* net_log); | |
| 114 virtual ~SSLConnectJob(); | 110 virtual ~SSLConnectJob(); |
| 115 | 111 |
| 116 // ConnectJob methods. | 112 // ConnectJob methods. |
| 117 virtual LoadState GetLoadState() const OVERRIDE; | 113 virtual LoadState GetLoadState() const OVERRIDE; |
| 118 | 114 |
| 119 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; | 115 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) OVERRIDE; |
| 120 | 116 |
| 121 private: | 117 private: |
| 122 enum State { | 118 enum State { |
| 123 STATE_TRANSPORT_CONNECT, | 119 STATE_TRANSPORT_CONNECT, |
| 124 STATE_TRANSPORT_CONNECT_COMPLETE, | 120 STATE_TRANSPORT_CONNECT_COMPLETE, |
| 125 STATE_SOCKS_CONNECT, | 121 STATE_SOCKS_CONNECT, |
| 126 STATE_SOCKS_CONNECT_COMPLETE, | 122 STATE_SOCKS_CONNECT_COMPLETE, |
| 127 STATE_TUNNEL_CONNECT, | 123 STATE_TUNNEL_CONNECT, |
| 128 STATE_TUNNEL_CONNECT_COMPLETE, | 124 STATE_TUNNEL_CONNECT_COMPLETE, |
| 129 STATE_SSL_CONNECT, | 125 STATE_SSL_CONNECT, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 171 |
| 176 class NET_EXPORT_PRIVATE SSLClientSocketPool | 172 class NET_EXPORT_PRIVATE SSLClientSocketPool |
| 177 : public ClientSocketPool, | 173 : public ClientSocketPool, |
| 178 public HigherLayeredPool, | 174 public HigherLayeredPool, |
| 179 public SSLConfigService::Observer { | 175 public SSLConfigService::Observer { |
| 180 public: | 176 public: |
| 181 typedef SSLSocketParams SocketParams; | 177 typedef SSLSocketParams SocketParams; |
| 182 | 178 |
| 183 // Only the pools that will be used are required. i.e. if you never | 179 // Only the pools that will be used are required. i.e. if you never |
| 184 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. | 180 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. |
| 185 SSLClientSocketPool( | 181 SSLClientSocketPool(int max_sockets, |
| 186 int max_sockets, | 182 int max_sockets_per_group, |
| 187 int max_sockets_per_group, | 183 ClientSocketPoolHistograms* histograms, |
| 188 ClientSocketPoolHistograms* histograms, | 184 HostResolver* host_resolver, |
| 189 HostResolver* host_resolver, | 185 CertVerifier* cert_verifier, |
| 190 CertVerifier* cert_verifier, | 186 ServerBoundCertService* server_bound_cert_service, |
| 191 ServerBoundCertService* server_bound_cert_service, | 187 TransportSecurityState* transport_security_state, |
| 192 TransportSecurityState* transport_security_state, | 188 CTVerifier* cert_transparency_verifier, |
| 193 CTVerifier* cert_transparency_verifier, | 189 const std::string& ssl_session_cache_shard, |
| 194 const std::string& ssl_session_cache_shard, | 190 ClientSocketFactory* client_socket_factory, |
| 195 ClientSocketFactory* client_socket_factory, | 191 TransportClientSocketPool* transport_pool, |
| 196 TransportClientSocketPool* transport_pool, | 192 SOCKSClientSocketPool* socks_pool, |
| 197 SOCKSClientSocketPool* socks_pool, | 193 HttpProxyClientSocketPool* http_proxy_pool, |
| 198 HttpProxyClientSocketPool* http_proxy_pool, | 194 SSLConfigService* ssl_config_service, |
| 199 SSLConfigService* ssl_config_service, | 195 NetLog* net_log); |
| 200 NetLog* net_log); | |
| 201 | 196 |
| 202 virtual ~SSLClientSocketPool(); | 197 virtual ~SSLClientSocketPool(); |
| 203 | 198 |
| 204 // ClientSocketPool implementation. | 199 // ClientSocketPool implementation. |
| 205 virtual int RequestSocket(const std::string& group_name, | 200 virtual int RequestSocket(const std::string& group_name, |
| 206 const void* connect_params, | 201 const void* connect_params, |
| 207 RequestPriority priority, | 202 RequestPriority priority, |
| 208 ClientSocketHandle* handle, | 203 ClientSocketHandle* handle, |
| 209 const CompletionCallback& callback, | 204 const CompletionCallback& callback, |
| 210 const BoundNetLog& net_log) OVERRIDE; | 205 const BoundNetLog& net_log) OVERRIDE; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; | 252 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; |
| 258 | 253 |
| 259 // SSLConfigService::Observer implementation. | 254 // SSLConfigService::Observer implementation. |
| 260 | 255 |
| 261 // When the user changes the SSL config, we flush all idle sockets so they | 256 // When the user changes the SSL config, we flush all idle sockets so they |
| 262 // won't get re-used. | 257 // won't get re-used. |
| 263 virtual void OnSSLConfigChanged() OVERRIDE; | 258 virtual void OnSSLConfigChanged() OVERRIDE; |
| 264 | 259 |
| 265 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { | 260 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { |
| 266 public: | 261 public: |
| 267 SSLConnectJobFactory( | 262 SSLConnectJobFactory(TransportClientSocketPool* transport_pool, |
| 268 TransportClientSocketPool* transport_pool, | 263 SOCKSClientSocketPool* socks_pool, |
| 269 SOCKSClientSocketPool* socks_pool, | 264 HttpProxyClientSocketPool* http_proxy_pool, |
| 270 HttpProxyClientSocketPool* http_proxy_pool, | 265 ClientSocketFactory* client_socket_factory, |
| 271 ClientSocketFactory* client_socket_factory, | 266 HostResolver* host_resolver, |
| 272 HostResolver* host_resolver, | 267 const SSLClientSocketContext& context, |
| 273 const SSLClientSocketContext& context, | 268 NetLog* net_log); |
| 274 NetLog* net_log); | |
| 275 | 269 |
| 276 virtual ~SSLConnectJobFactory() {} | 270 virtual ~SSLConnectJobFactory() {} |
| 277 | 271 |
| 278 // ClientSocketPoolBase::ConnectJobFactory methods. | 272 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 279 virtual scoped_ptr<ConnectJob> NewConnectJob( | 273 virtual scoped_ptr<ConnectJob> NewConnectJob( |
| 280 const std::string& group_name, | 274 const std::string& group_name, |
| 281 const PoolBase::Request& request, | 275 const PoolBase::Request& request, |
| 282 ConnectJob::Delegate* delegate) const OVERRIDE; | 276 ConnectJob::Delegate* delegate) const OVERRIDE; |
| 283 | 277 |
| 284 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 278 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 301 HttpProxyClientSocketPool* const http_proxy_pool_; | 295 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 302 PoolBase base_; | 296 PoolBase base_; |
| 303 const scoped_refptr<SSLConfigService> ssl_config_service_; | 297 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 304 | 298 |
| 305 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 299 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
| 306 }; | 300 }; |
| 307 | 301 |
| 308 } // namespace net | 302 } // namespace net |
| 309 | 303 |
| 310 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 304 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |