Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: net/socket/ssl_client_socket_pool.h

Issue 328903004: SSL Connect Job Waiting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bugs related to memory management and early exits in DoSSLConnectComplete Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b0aceaca4323d2692f95da92f260d90dfcdeb043 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"
@@ -17,6 +19,7 @@
#include "net/socket/client_socket_pool_base.h"
#include "net/socket/client_socket_pool_histograms.h"
#include "net/socket/ssl_client_socket.h"
+#include "net/socket/ssl_client_socket_openssl.h"
wtc 2014/06/19 19:38:11 Remove this header.
mshelley1 2014/06/24 17:03:59 Done.
#include "net/ssl/ssl_config_service.h"
namespace net {
@@ -98,19 +101,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,
+ 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 +125,9 @@ class SSLConnectJob : public ConnectJob {
virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE;
+ // Allows a command line flag to enable SSLConnectJob waiting
wtc 2014/06/19 19:38:11 Nit: the comment should avoid describing a particu
mshelley1 2014/06/24 17:03:59 Done.
+ static NET_EXPORT void EnableJobWaiting(bool enable);
+
private:
enum State {
STATE_TRANSPORT_CONNECT,
@@ -126,6 +136,8 @@ 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_NONE,
@@ -142,9 +154,20 @@ class SSLConnectJob : public ConnectJob {
int DoSOCKSConnectComplete(int result);
int DoTunnelConnect();
int DoTunnelConnectComplete(int result);
+ int DoCreateSSLSocket();
+ int DoCheckForResume();
int DoSSLConnect();
int DoSSLConnectComplete(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();
+
+ static bool enable_job_waiting_;
+
// Returns the initial state for the state machine based on the
// |connection_type|.
static State GetInitialState(SSLSocketParams::ConnectionType connection_type);
@@ -164,10 +187,11 @@ 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_;
+ PendingJobList* pending_jobs_;
HttpResponseInfo error_response_info_;
DISALLOW_COPY_AND_ASSIGN(SSLConnectJob);
@@ -284,6 +308,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 +320,7 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
const SSLClientSocketContext context_;
base::TimeDelta timeout_;
NetLog* net_log_;
+ scoped_ptr<PendingJobMap> pending_jobs_map_;
wtc 2014/06/19 19:38:11 It saves a memory allocation from the heap to decl
mshelley1 2014/06/24 17:03:59 Done.
DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory);
};

Powered by Google App Engine
This is Rietveld 408576698