Chromium Code Reviews| Index: net/socket/ssl_client_socket_pool.h |
| diff --git a/net/socket/ssl_client_socket_pool.h b/net/socket/ssl_client_socket_pool.h |
| index e03b76ade6ab5946e2d981e7d7802b1cb70d6dba..d25ab8388a6d8bf1642d02a071862fe387f3a40b 100644 |
| --- a/net/socket/ssl_client_socket_pool.h |
| +++ b/net/socket/ssl_client_socket_pool.h |
| @@ -5,7 +5,9 @@ |
| #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| #define NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| +#include <map> |
| #include <string> |
| +#include <vector> |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -98,19 +100,23 @@ class NET_EXPORT_PRIVATE SSLSocketParams |
| // connection as specified in the params. |
| class SSLConnectJob : public ConnectJob { |
| public: |
| - SSLConnectJob( |
| - const std::string& group_name, |
| - RequestPriority priority, |
| - const scoped_refptr<SSLSocketParams>& params, |
| - const base::TimeDelta& timeout_duration, |
| - TransportClientSocketPool* transport_pool, |
| - SOCKSClientSocketPool* socks_pool, |
| - HttpProxyClientSocketPool* http_proxy_pool, |
| - ClientSocketFactory* client_socket_factory, |
| - HostResolver* host_resolver, |
| - const SSLClientSocketContext& context, |
| - Delegate* delegate, |
| - NetLog* net_log); |
| + // List of SSLConnectJobs that are either in the process of connecting |
| + // to or waiting to connect to the same server. |
| + typedef std::vector<SSLConnectJob*> PendingJobList; |
| + |
| + SSLConnectJob(const std::string& group_name, |
|
wtc
2014/06/26 17:48:17
Please move the comment here:
// Note: the SSLC
|
| + RequestPriority priority, |
| + const scoped_refptr<SSLSocketParams>& params, |
| + const base::TimeDelta& timeout_duration, |
| + TransportClientSocketPool* transport_pool, |
| + SOCKSClientSocketPool* socks_pool, |
| + HttpProxyClientSocketPool* http_proxy_pool, |
| + ClientSocketFactory* client_socket_factory, |
| + HostResolver* host_resolver, |
| + const SSLClientSocketContext& context, |
| + PendingJobList* pending_jobs_list, |
| + Delegate* delegate, |
| + NetLog* net_log); |
| virtual ~SSLConnectJob(); |
| // ConnectJob methods. |
| @@ -118,6 +124,14 @@ class SSLConnectJob : public ConnectJob { |
| virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; |
| + // Enables or disables SSLConnectJob waiting. |
| + // If enabled, simultaneous attempts to connect to the same server |
| + // will be serialized until an SSL session is cached, allowing those |
| + // handshakes to perform a resumption handshake. |
| + static NET_EXPORT void EnableJobWaiting(bool enable); |
| + |
| + static bool GetEnableJobWaiting(); |
|
wtc
2014/06/26 17:48:17
Nit: this function can be named "JobWaitingEnabled
|
| + |
| private: |
| enum State { |
| STATE_TRANSPORT_CONNECT, |
| @@ -126,8 +140,11 @@ class SSLConnectJob : public ConnectJob { |
| STATE_SOCKS_CONNECT_COMPLETE, |
| STATE_TUNNEL_CONNECT, |
| STATE_TUNNEL_CONNECT_COMPLETE, |
| + STATE_CREATE_SSL_SOCKET, |
| + STATE_CHECK_FOR_RESUME, |
| STATE_SSL_CONNECT, |
| STATE_SSL_CONNECT_COMPLETE, |
| + STATE_PROCESS_PENDING_JOBS, |
| STATE_NONE, |
| }; |
| @@ -142,8 +159,18 @@ class SSLConnectJob : public ConnectJob { |
| int DoSOCKSConnectComplete(int result); |
| int DoTunnelConnect(); |
| int DoTunnelConnectComplete(int result); |
| + int DoCreateSSLSocket(); |
| + int DoCheckForResume(); |
| int DoSSLConnect(); |
| int DoSSLConnectComplete(int result); |
| + int DoProcessPendingJobs(int result); |
| + |
| + // Decides how pending jobs should continue their connection |
| + // based upon the success or failure of the leading job. |
| + void ProcessPendingJobs(int result); |
| + |
| + // Tells a waiting SSLConnectJob to resume its SSL connection. |
| + void ResumeSSLConnection(); |
| // Returns the initial state for the state machine based on the |
| // |connection_type|. |
| @@ -154,6 +181,7 @@ class SSLConnectJob : public ConnectJob { |
| // Otherwise, it returns a net error code. |
| virtual int ConnectInternal() OVERRIDE; |
| + static bool enable_job_waiting_; |
| scoped_refptr<SSLSocketParams> params_; |
| TransportClientSocketPool* const transport_pool_; |
| SOCKSClientSocketPool* const socks_pool_; |
| @@ -164,10 +192,12 @@ class SSLConnectJob : public ConnectJob { |
| const SSLClientSocketContext context_; |
| State next_state_; |
| - CompletionCallback callback_; |
| + CompletionCallback io_callback_; |
| scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
| scoped_ptr<SSLClientSocket> ssl_socket_; |
| + // TODO(mshelley) ensure that these pointers are deleted. |
| + PendingJobList* pending_jobs_; |
| HttpResponseInfo error_response_info_; |
| DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); |
| @@ -284,6 +314,10 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool |
| virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| private: |
| + // Maps SSLConnectJob group names to lists of pending connect jobs to |
| + // that group name. |
| + typedef std::map<std::string, SSLConnectJob::PendingJobList*> PendingJobMap; |
| + |
| TransportClientSocketPool* const transport_pool_; |
| SOCKSClientSocketPool* const socks_pool_; |
| HttpProxyClientSocketPool* const http_proxy_pool_; |
| @@ -292,6 +326,7 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool |
| const SSLClientSocketContext context_; |
| base::TimeDelta timeout_; |
| NetLog* net_log_; |
| + scoped_ptr<PendingJobMap> pending_jobs_map_; |
|
wtc
2014/06/26 17:48:17
Please declare this member as a non-pointer, if th
|
| DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); |
| }; |