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

Unified Diff: net/socket/ssl_client_socket_pool.h

Issue 384873002: This CL changes the lifespan of SSLConnectJobMessengers so that they are created only when needed, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@useloop
Patch Set: Added documentation and removed the cache_key argument from ConnectionCompleteCallback Created 6 years, 4 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 cfc7c0dfbabd3832d89d29ebc511b145d64226fd..b62230443709761ac30ae5041e7505d496fbaeca 100644
--- a/net/socket/ssl_client_socket_pool.h
+++ b/net/socket/ssl_client_socket_pool.h
@@ -114,8 +114,12 @@ class SSLConnectJobMessenger {
};
typedef std::vector<SocketAndCallback> SSLPendingSocketsAndCallbacks;
+ typedef base::Callback<void()> ConnectionCompleteCallback;
Ryan Sleevi 2014/08/14 01:20:20 We have a typedef for this already - base::Closure
mshelley 2014/08/14 20:01:36 Done.
- SSLConnectJobMessenger();
+ // |connection_complete_callback| is used to inform the client socket pool
+ // that a connection monitored by the SSLConnectJobMessenger has completed.
+ SSLConnectJobMessenger(
+ const ConnectionCompleteCallback& connection_complete_callback);
wtc 2014/08/14 00:46:46 DESIGN: instead of an abstract callback function,
Ryan Sleevi 2014/08/14 01:20:20 I recommended against this, to avoid introducing a
mshelley 2014/08/14 20:01:37 So is the benefit of passing in the pointer direct
~SSLConnectJobMessenger();
// Removes |socket| from the set of sockets being monitored. This
@@ -151,33 +155,47 @@ class SSLConnectJobMessenger {
void RunAllCallbacks(
const SSLPendingSocketsAndCallbacks& pending_socket_and_callbacks);
- base::WeakPtrFactory<SSLConnectJobMessenger> weak_factory_;
-
SSLPendingSocketsAndCallbacks pending_sockets_and_callbacks_;
// Note: this field is a vector to allow for future design changes. Currently,
// this vector should only ever have one entry.
std::vector<SSLClientSocket*> connecting_sockets_;
+
+ ConnectionCompleteCallback connection_complete_callback_;
+
+ base::WeakPtrFactory<SSLConnectJobMessenger> weak_factory_;
};
// SSLConnectJob handles the SSL handshake after setting up the underlying
// connection as specified in the params.
class SSLConnectJob : public ConnectJob {
public:
+ // Callback to allow the SSLConnectJob to obtain an SSLConnectJobMessenger to
+ // coordinate connecting. The SSLConnectJob will supply a unique identifer
+ // (ex: the SSL session cache key), with the expectation that the same
+ // Messenger
+ // will be returned for all such ConnectJobs.
wtc 2014/08/14 00:46:46 Please reformat this comment block.
mshelley 2014/08/14 20:01:37 Done.
+ //
+ // Note: It will only be called for situations where the SSL session cache
+ // does not already have a candidate session to resume.
+ typedef base::Callback<SSLConnectJobMessenger*(const std::string&)>
+ GetMessengerForUncachedSessionCallback;
wtc 2014/08/14 00:46:46 Nit: I would shorten this type to "GetMessengerCal
mshelley 2014/08/14 20:01:37 Done.
+
// Note: the SSLConnectJob does not own |messenger| so it must outlive the
// job.
- 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,
- SSLConnectJobMessenger* messenger,
- Delegate* delegate,
- NetLog* net_log);
+ 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,
+ const GetMessengerForUncachedSessionCallback& uncached_session_callback,
wtc 2014/08/14 00:46:46 Between the "get messenger" and the "uncached sess
wtc 2014/08/14 00:46:46 DESIGN: I would just pass a SSLClientSocketPool* p
Ryan Sleevi 2014/08/14 01:20:20 Same comment re: coupling. To date, there's nothi
mshelley 2014/08/14 20:01:37 Done.
+ Delegate* delegate,
+ NetLog* net_log);
virtual ~SSLConnectJob();
// ConnectJob methods.
@@ -245,6 +263,9 @@ class SSLConnectJob : public ConnectJob {
SSLConnectJobMessenger* messenger_;
HttpResponseInfo error_response_info_;
+ SSLConnectJob::GetMessengerForUncachedSessionCallback
wtc 2014/08/14 00:46:46 You should be able to omit "SSLConnectJob::".
mshelley 2014/08/14 20:01:37 Done.
+ uncached_session_callback_;
+
base::WeakPtrFactory<SSLConnectJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SSLConnectJob);
@@ -330,8 +351,16 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
// HigherLayeredPool implementation.
virtual bool CloseOneIdleConnection() OVERRIDE;
+ // Creates an SSLConnectJobMessenger for the given ssl session |cache_key|
wtc 2014/08/14 00:46:45 This comment is not accurate because the method ma
mshelley 2014/08/14 20:01:37 Done.
+ // and stores it in |messenger_map_|. Returns the new SSLConnectJobMessenger.
+ SSLConnectJobMessenger* AddSSLConnectJobMessenger(
+ const std::string& cache_key);
+ void DeleteSSLConnectJobMessenger(const std::string& cache_key);
+
private:
typedef ClientSocketPoolBase<SSLSocketParams> PoolBase;
+ // Maps SSLConnectJob cache keys to SSLConnectJobMessenger objects.
+ typedef std::map<std::string, SSLConnectJobMessenger*> MessengerMap;
// SSLConfigService::Observer implementation.
@@ -347,7 +376,8 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
ClientSocketFactory* client_socket_factory,
HostResolver* host_resolver,
const SSLClientSocketContext& context,
- bool enable_ssl_connect_job_waiting,
+ SSLConnectJob::GetMessengerForUncachedSessionCallback
+ uncached_session_callback,
wtc 2014/08/14 00:46:46 Rename this "get_messenger_callback".
mshelley 2014/08/14 20:01:36 Done.
NetLog* net_log);
virtual ~SSLConnectJobFactory();
@@ -361,9 +391,6 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
virtual base::TimeDelta ConnectionTimeout() const OVERRIDE;
private:
- // Maps SSLConnectJob cache keys to SSLConnectJobMessenger objects.
- typedef std::map<std::string, SSLConnectJobMessenger*> MessengerMap;
-
TransportClientSocketPool* const transport_pool_;
SOCKSClientSocketPool* const socks_pool_;
HttpProxyClientSocketPool* const http_proxy_pool_;
@@ -371,13 +398,9 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
HostResolver* const host_resolver_;
const SSLClientSocketContext context_;
base::TimeDelta timeout_;
- bool enable_ssl_connect_job_waiting_;
+ SSLConnectJob::GetMessengerForUncachedSessionCallback
+ uncached_session_callback_;
wtc 2014/08/14 00:46:45 Rename this "get_messenger_callback".
mshelley 2014/08/14 20:01:36 Done.
NetLog* net_log_;
- // |messenger_map_| is currently a pointer so that an element can be
- // added to it inside of the const method NewConnectJob. In the future,
- // elements will be added in a different method.
- // TODO(mshelley) Change this to a non-pointer.
- scoped_ptr<MessengerMap> messenger_map_;
DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory);
};
@@ -387,6 +410,8 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
HttpProxyClientSocketPool* const http_proxy_pool_;
PoolBase base_;
const scoped_refptr<SSLConfigService> ssl_config_service_;
+ MessengerMap messenger_map_;
+ bool enable_ssl_connect_job_waiting_;
DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool);
};

Powered by Google App Engine
This is Rietveld 408576698