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

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: Removed FormatSessionCacheKey function. Created 6 years, 5 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 87b1212995dffe3c212806d44325c55a6c72ec99..457ce066e974ad752084bd737ca70ee5233e7928 100644
--- a/net/socket/ssl_client_socket_pool.h
+++ b/net/socket/ssl_client_socket_pool.h
@@ -142,6 +142,9 @@ class NET_EXPORT_PRIVATE SSLConnectJobMessenger {
// and runs that socket's resumption callback.
void ConnectNewLeader();
+ // Returns true if this SSLConnectJobMessenger is still in use.
+ bool IsNeeded();
Ryan Sleevi 2014/07/25 21:40:07 What does "in use" mean? By who? Better to expand
mshelley 2014/07/28 21:05:32 Done.
+
private:
// Runs all callbacks stored in |pending_sockets_and_callbacks_|.
void RunAllJobs(
@@ -156,6 +159,10 @@ class NET_EXPORT_PRIVATE SSLConnectJobMessenger {
// connection as specified in the params.
class SSLConnectJob : public ConnectJob {
public:
+ typedef base::Callback<SSLConnectJobMessenger*(std::string)>
Ryan Sleevi 2014/07/25 21:40:07 What is the ownership semantics of the Messenger p
mshelley 2014/07/28 21:05:32 Done.
+ AddMessengerCallback;
+ typedef base::Callback<void(std::string)> DeleteMessengerCallback;
+
// Note: the SSLConnectJob does not own |messenger|.
// so it must outlive the job.
SSLConnectJob(const std::string& group_name,
@@ -169,6 +176,8 @@ class SSLConnectJob : public ConnectJob {
HostResolver* host_resolver,
const SSLClientSocketContext& context,
SSLConnectJobMessenger* messenger,
+ AddMessengerCallback add_messenger_calblack,
+ DeleteMessengerCallback delete_messenger_callback,
Delegate* delegate,
NetLog* net_log);
virtual ~SSLConnectJob();
@@ -212,6 +221,14 @@ class SSLConnectJob : public ConnectJob {
// Tells a waiting SSLConnectJob to resume its SSL connection.
void ResumeSSLConnection();
+ // Retrieves an SSLConnectJobMessenger from the SSLConnectJobFactory and
+ // stores it in the messenger_ field.
+ void GetMessenger(std::string cache_key);
+
+ // Deletes this job's SSLConnectJobMessenger from the SSLConnectJobFactory's
+ // map of messengers, and deletes the messenger itself.
+ void DeleteMessenger(std::string cache_key);
Ryan Sleevi 2014/07/25 21:40:07 This seems like a layering violation. The SSLConne
mshelley 2014/07/28 21:05:32 Right now, the SSLConnectJobFactory manages the li
+
// Returns the initial state for the state machine based on the
// |connection_type|.
static State GetInitialState(SSLSocketParams::ConnectionType connection_type);
@@ -240,6 +257,9 @@ class SSLConnectJob : public ConnectJob {
base::WeakPtrFactory<SSLConnectJob> weak_factory_;
+ AddMessengerCallback add_messenger_callback_;
+ DeleteMessengerCallback delete_messenger_callback_;
Ryan Sleevi 2014/07/25 21:40:07 What are these callbacks? Connect() can be called
mshelley 2014/07/28 21:05:32 These are callbacks to methods of the SSLConnectJo
+
DISALLOW_COPY_AND_ASSIGN(SSLConnectJob);
};
@@ -345,11 +365,18 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
virtual ~SSLConnectJobFactory() {}
+ // Creates an SSLConnectJobMessenger for the given |cache_key| and stores it
+ // in |messenger_map_|. Returns the new SSLConnectJobMessenger.
+ SSLConnectJobMessenger* AddSSLConnectJobMessenger(std::string cache_key);
+
+ // Deletes the entry for the given |cache_key| from the |messenger_map_|.
+ void DeleteSSLConnectJobMessenger(std::string cache_key);
+
// ClientSocketPoolBase::ConnectJobFactory methods.
virtual scoped_ptr<ConnectJob> NewConnectJob(
const std::string& group_name,
const PoolBase::Request& request,
- ConnectJob::Delegate* delegate) const OVERRIDE;
+ ConnectJob::Delegate* delegate) OVERRIDE;
virtual base::TimeDelta ConnectionTimeout() const OVERRIDE;
@@ -365,7 +392,7 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
const SSLClientSocketContext context_;
base::TimeDelta timeout_;
NetLog* net_log_;
- scoped_ptr<MessengerMap> messenger_map_;
+ MessengerMap messenger_map_;
DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory);
};

Powered by Google App Engine
This is Rietveld 408576698