Chromium Code Reviews| 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 <map> | |
| 8 #include <string> | 9 #include <string> |
| 10 #include <vector> | |
| 9 | 11 |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 13 #include "net/base/privacy_mode.h" | 15 #include "net/base/privacy_mode.h" |
| 14 #include "net/dns/host_resolver.h" | 16 #include "net/dns/host_resolver.h" |
| 15 #include "net/http/http_response_info.h" | 17 #include "net/http/http_response_info.h" |
| 16 #include "net/socket/client_socket_pool.h" | 18 #include "net/socket/client_socket_pool.h" |
| 17 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
| 18 #include "net/socket/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
| 19 #include "net/socket/ssl_client_socket.h" | 21 #include "net/socket/ssl_client_socket.h" |
| 22 #include "net/socket/ssl_client_socket_openssl.h" | |
| 20 #include "net/ssl/ssl_config_service.h" | 23 #include "net/ssl/ssl_config_service.h" |
| 21 | 24 |
| 22 namespace net { | 25 namespace net { |
| 23 | 26 |
| 24 class CertVerifier; | 27 class CertVerifier; |
| 25 class ClientSocketFactory; | 28 class ClientSocketFactory; |
| 26 class ConnectJobFactory; | 29 class ConnectJobFactory; |
| 27 class CTVerifier; | 30 class CTVerifier; |
| 28 class HostPortPair; | 31 class HostPortPair; |
| 29 class HttpProxyClientSocketPool; | 32 class HttpProxyClientSocketPool; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 const bool want_spdy_over_npn_; | 94 const bool want_spdy_over_npn_; |
| 92 bool ignore_limits_; | 95 bool ignore_limits_; |
| 93 | 96 |
| 94 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); | 97 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 // SSLConnectJob handles the SSL handshake after setting up the underlying | 100 // SSLConnectJob handles the SSL handshake after setting up the underlying |
| 98 // connection as specified in the params. | 101 // connection as specified in the params. |
| 99 class SSLConnectJob : public ConnectJob { | 102 class SSLConnectJob : public ConnectJob { |
| 100 public: | 103 public: |
| 101 SSLConnectJob( | 104 typedef std::vector<SSLConnectJob*> PendingJobList; |
|
wtc
2014/06/17 17:44:41
Nit: it would be nice to document this type. For e
mshelley1
2014/06/18 18:53:50
Done.
| |
| 102 const std::string& group_name, | 105 |
| 103 RequestPriority priority, | 106 SSLConnectJob(const std::string& group_name, |
| 104 const scoped_refptr<SSLSocketParams>& params, | 107 RequestPriority priority, |
| 105 const base::TimeDelta& timeout_duration, | 108 const scoped_refptr<SSLSocketParams>& params, |
| 106 TransportClientSocketPool* transport_pool, | 109 const base::TimeDelta& timeout_duration, |
| 107 SOCKSClientSocketPool* socks_pool, | 110 TransportClientSocketPool* transport_pool, |
| 108 HttpProxyClientSocketPool* http_proxy_pool, | 111 SOCKSClientSocketPool* socks_pool, |
| 109 ClientSocketFactory* client_socket_factory, | 112 HttpProxyClientSocketPool* http_proxy_pool, |
| 110 HostResolver* host_resolver, | 113 ClientSocketFactory* client_socket_factory, |
| 111 const SSLClientSocketContext& context, | 114 HostResolver* host_resolver, |
| 112 Delegate* delegate, | 115 const SSLClientSocketContext& context, |
| 113 NetLog* net_log); | 116 Delegate* delegate, |
| 117 NetLog* net_log, | |
| 118 PendingJobList* pending); | |
|
wtc
2014/06/17 17:44:41
1. Nit: I suggest naming this parameter "pending_j
mshelley1
2014/06/18 18:53:50
Done.
| |
| 114 virtual ~SSLConnectJob(); | 119 virtual ~SSLConnectJob(); |
| 115 | 120 |
| 116 // ConnectJob methods. | 121 // ConnectJob methods. |
| 117 virtual LoadState GetLoadState() const OVERRIDE; | 122 virtual LoadState GetLoadState() const OVERRIDE; |
| 118 | 123 |
| 119 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; | 124 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; |
| 120 | 125 |
| 126 static NET_EXPORT void EnableJobWaiting(bool enable); | |
|
wtc
2014/06/17 17:44:41
Nit: please document this method.
mshelley1
2014/06/18 18:53:50
Done.
| |
| 127 | |
| 121 private: | 128 private: |
| 122 enum State { | 129 enum State { |
| 123 STATE_TRANSPORT_CONNECT, | 130 STATE_TRANSPORT_CONNECT, |
| 124 STATE_TRANSPORT_CONNECT_COMPLETE, | 131 STATE_TRANSPORT_CONNECT_COMPLETE, |
| 125 STATE_SOCKS_CONNECT, | 132 STATE_SOCKS_CONNECT, |
| 126 STATE_SOCKS_CONNECT_COMPLETE, | 133 STATE_SOCKS_CONNECT_COMPLETE, |
| 127 STATE_TUNNEL_CONNECT, | 134 STATE_TUNNEL_CONNECT, |
| 128 STATE_TUNNEL_CONNECT_COMPLETE, | 135 STATE_TUNNEL_CONNECT_COMPLETE, |
| 136 STATE_CREATE_SSL_SOCKET, | |
| 137 STATE_CHECK_FOR_RESUME, | |
| 129 STATE_SSL_CONNECT, | 138 STATE_SSL_CONNECT, |
| 130 STATE_SSL_CONNECT_COMPLETE, | 139 STATE_SSL_CONNECT_COMPLETE, |
| 131 STATE_NONE, | 140 STATE_NONE, |
| 132 }; | 141 }; |
| 133 | 142 |
| 134 void OnIOComplete(int result); | 143 void OnIOComplete(int result); |
| 135 | 144 |
| 136 // Runs the state transition loop. | 145 // Runs the state transition loop. |
| 137 int DoLoop(int result); | 146 int DoLoop(int result); |
| 138 | 147 |
| 139 int DoTransportConnect(); | 148 int DoTransportConnect(); |
| 140 int DoTransportConnectComplete(int result); | 149 int DoTransportConnectComplete(int result); |
| 141 int DoSOCKSConnect(); | 150 int DoSOCKSConnect(); |
| 142 int DoSOCKSConnectComplete(int result); | 151 int DoSOCKSConnectComplete(int result); |
| 143 int DoTunnelConnect(); | 152 int DoTunnelConnect(); |
| 144 int DoTunnelConnectComplete(int result); | 153 int DoTunnelConnectComplete(int result); |
| 154 int DoCreateSSLSocket(); | |
| 155 int DoCheckForResume(); | |
| 145 int DoSSLConnect(); | 156 int DoSSLConnect(); |
| 146 int DoSSLConnectComplete(int result); | 157 int DoSSLConnectComplete(int result); |
| 147 | 158 |
| 159 // Decides how pending jobs should continue their connection | |
| 160 // based upon the success or failure of the leading job. | |
| 161 void ProcessPendingJobs(int result); | |
| 162 void ResumeSSLConnection(); | |
|
wtc
2014/06/17 17:44:41
Please document this method.
mshelley1
2014/06/18 18:53:51
Done.
| |
| 163 State GetNextConnectState(bool enabled); | |
|
wtc
2014/06/17 17:44:41
Delete this unused method declaration.
mshelley1
2014/06/18 18:53:51
Done.
| |
| 164 | |
| 165 std::string GetSessionCacheKey(); | |
|
wtc
2014/06/17 17:44:41
Delete this unused method.
mshelley1
2014/06/18 18:53:50
Done.
| |
| 166 | |
| 167 static bool enable_job_waiting_; | |
| 168 | |
| 148 // Returns the initial state for the state machine based on the | 169 // Returns the initial state for the state machine based on the |
| 149 // |connection_type|. | 170 // |connection_type|. |
| 150 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); | 171 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); |
| 151 | 172 |
| 152 // Starts the SSL connection process. Returns OK on success and | 173 // Starts the SSL connection process. Returns OK on success and |
| 153 // ERR_IO_PENDING if it cannot immediately service the request. | 174 // ERR_IO_PENDING if it cannot immediately service the request. |
| 154 // Otherwise, it returns a net error code. | 175 // Otherwise, it returns a net error code. |
| 155 virtual int ConnectInternal() OVERRIDE; | 176 virtual int ConnectInternal() OVERRIDE; |
| 156 | 177 |
| 157 scoped_refptr<SSLSocketParams> params_; | 178 scoped_refptr<SSLSocketParams> params_; |
| 158 TransportClientSocketPool* const transport_pool_; | 179 TransportClientSocketPool* const transport_pool_; |
| 159 SOCKSClientSocketPool* const socks_pool_; | 180 SOCKSClientSocketPool* const socks_pool_; |
| 160 HttpProxyClientSocketPool* const http_proxy_pool_; | 181 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 161 ClientSocketFactory* const client_socket_factory_; | 182 ClientSocketFactory* const client_socket_factory_; |
| 162 HostResolver* const host_resolver_; | 183 HostResolver* const host_resolver_; |
| 163 | 184 |
| 164 const SSLClientSocketContext context_; | 185 const SSLClientSocketContext context_; |
| 165 | 186 |
| 166 State next_state_; | 187 State next_state_; |
| 167 CompletionCallback callback_; | 188 CompletionCallback io_callback_; |
| 168 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 189 scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
| 169 scoped_ptr<SSLClientSocket> ssl_socket_; | 190 scoped_ptr<SSLClientSocket> ssl_socket_; |
| 170 | 191 |
| 192 PendingJobList* pending_jobs_; | |
| 171 HttpResponseInfo error_response_info_; | 193 HttpResponseInfo error_response_info_; |
| 172 | 194 |
| 173 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); | 195 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); |
| 174 }; | 196 }; |
| 175 | 197 |
| 176 class NET_EXPORT_PRIVATE SSLClientSocketPool | 198 class NET_EXPORT_PRIVATE SSLClientSocketPool |
| 177 : public ClientSocketPool, | 199 : public ClientSocketPool, |
| 178 public HigherLayeredPool, | 200 public HigherLayeredPool, |
| 179 public SSLConfigService::Observer { | 201 public SSLConfigService::Observer { |
| 180 public: | 202 public: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 | 299 |
| 278 // ClientSocketPoolBase::ConnectJobFactory methods. | 300 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 279 virtual scoped_ptr<ConnectJob> NewConnectJob( | 301 virtual scoped_ptr<ConnectJob> NewConnectJob( |
| 280 const std::string& group_name, | 302 const std::string& group_name, |
| 281 const PoolBase::Request& request, | 303 const PoolBase::Request& request, |
| 282 ConnectJob::Delegate* delegate) const OVERRIDE; | 304 ConnectJob::Delegate* delegate) const OVERRIDE; |
| 283 | 305 |
| 284 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 306 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| 285 | 307 |
| 286 private: | 308 private: |
| 309 typedef std::map<std::string, SSLConnectJob::PendingJobList*> PendingJobMap; | |
|
wtc
2014/06/17 17:44:41
Please document this map. In particular, what is t
mshelley1
2014/06/18 18:53:51
Done.
| |
| 310 | |
| 287 TransportClientSocketPool* const transport_pool_; | 311 TransportClientSocketPool* const transport_pool_; |
| 288 SOCKSClientSocketPool* const socks_pool_; | 312 SOCKSClientSocketPool* const socks_pool_; |
| 289 HttpProxyClientSocketPool* const http_proxy_pool_; | 313 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 290 ClientSocketFactory* const client_socket_factory_; | 314 ClientSocketFactory* const client_socket_factory_; |
| 291 HostResolver* const host_resolver_; | 315 HostResolver* const host_resolver_; |
| 292 const SSLClientSocketContext context_; | 316 const SSLClientSocketContext context_; |
| 293 base::TimeDelta timeout_; | 317 base::TimeDelta timeout_; |
| 294 NetLog* net_log_; | 318 NetLog* net_log_; |
| 319 PendingJobMap* pending_jobs_; | |
|
wtc
2014/06/17 17:44:41
Please document who owns pending_jobs_. If SSLClie
mshelley1
2014/06/18 18:53:51
Done.
| |
| 295 | 320 |
| 296 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); | 321 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); |
| 297 }; | 322 }; |
| 298 | 323 |
| 299 TransportClientSocketPool* const transport_pool_; | 324 TransportClientSocketPool* const transport_pool_; |
| 300 SOCKSClientSocketPool* const socks_pool_; | 325 SOCKSClientSocketPool* const socks_pool_; |
| 301 HttpProxyClientSocketPool* const http_proxy_pool_; | 326 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 302 PoolBase base_; | 327 PoolBase base_; |
| 303 const scoped_refptr<SSLConfigService> ssl_config_service_; | 328 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 304 | 329 |
| 305 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 330 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
| 306 }; | 331 }; |
| 307 | 332 |
| 308 } // namespace net | 333 } // namespace net |
| 309 | 334 |
| 310 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 335 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |