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

Side by Side 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 commenting issues and prevented PendingJobs from modifying pending_jobs_. 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 unified diff | Download patch
OLDNEW
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"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const bool want_spdy_over_npn_; 93 const bool want_spdy_over_npn_;
92 bool ignore_limits_; 94 bool ignore_limits_;
93 95
94 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); 96 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams);
95 }; 97 };
96 98
97 // SSLConnectJob handles the SSL handshake after setting up the underlying 99 // SSLConnectJob handles the SSL handshake after setting up the underlying
98 // connection as specified in the params. 100 // connection as specified in the params.
99 class SSLConnectJob : public ConnectJob { 101 class SSLConnectJob : public ConnectJob {
100 public: 102 public:
101 SSLConnectJob( 103 // List of SSLConnectJobs that are either in the process of connecting
102 const std::string& group_name, 104 // to or waiting to connect to the same server.
103 RequestPriority priority, 105 typedef std::vector<SSLConnectJob*> PendingJobList;
104 const scoped_refptr<SSLSocketParams>& params, 106
105 const base::TimeDelta& timeout_duration, 107 SSLConnectJob(const std::string& group_name,
106 TransportClientSocketPool* transport_pool, 108 RequestPriority priority,
107 SOCKSClientSocketPool* socks_pool, 109 const scoped_refptr<SSLSocketParams>& params,
108 HttpProxyClientSocketPool* http_proxy_pool, 110 const base::TimeDelta& timeout_duration,
109 ClientSocketFactory* client_socket_factory, 111 TransportClientSocketPool* transport_pool,
110 HostResolver* host_resolver, 112 SOCKSClientSocketPool* socks_pool,
111 const SSLClientSocketContext& context, 113 HttpProxyClientSocketPool* http_proxy_pool,
112 Delegate* delegate, 114 ClientSocketFactory* client_socket_factory,
113 NetLog* net_log); 115 HostResolver* host_resolver,
116 const SSLClientSocketContext& context,
117 PendingJobList* pending_jobs_list,
118 Delegate* delegate,
119 NetLog* net_log);
114 virtual ~SSLConnectJob(); 120 virtual ~SSLConnectJob();
115 121
116 // ConnectJob methods. 122 // ConnectJob methods.
117 virtual LoadState GetLoadState() const OVERRIDE; 123 virtual LoadState GetLoadState() const OVERRIDE;
118 124
119 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; 125 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE;
120 126
127 // Enables or disables SSLConnectJob waiting.
128 // If enabled, simultaneous attempts to connect to the same server
129 // will be serialized until an SSL session is cached, allowing those
130 // handshakes to perform a resumption handshake.
131 static NET_EXPORT void EnableJobWaiting(bool enable);
132
133 static bool GetEnableJobWaiting();
134
121 private: 135 private:
122 enum State { 136 enum State {
123 STATE_TRANSPORT_CONNECT, 137 STATE_TRANSPORT_CONNECT,
124 STATE_TRANSPORT_CONNECT_COMPLETE, 138 STATE_TRANSPORT_CONNECT_COMPLETE,
125 STATE_SOCKS_CONNECT, 139 STATE_SOCKS_CONNECT,
126 STATE_SOCKS_CONNECT_COMPLETE, 140 STATE_SOCKS_CONNECT_COMPLETE,
127 STATE_TUNNEL_CONNECT, 141 STATE_TUNNEL_CONNECT,
128 STATE_TUNNEL_CONNECT_COMPLETE, 142 STATE_TUNNEL_CONNECT_COMPLETE,
143 STATE_CREATE_SSL_SOCKET,
144 STATE_CHECK_FOR_RESUME,
129 STATE_SSL_CONNECT, 145 STATE_SSL_CONNECT,
130 STATE_SSL_CONNECT_COMPLETE, 146 STATE_SSL_CONNECT_COMPLETE,
131 STATE_NONE, 147 STATE_NONE,
132 }; 148 };
133 149
134 void OnIOComplete(int result); 150 void OnIOComplete(int result);
135 151
136 // Runs the state transition loop. 152 // Runs the state transition loop.
137 int DoLoop(int result); 153 int DoLoop(int result);
138 154
139 int DoTransportConnect(); 155 int DoTransportConnect();
140 int DoTransportConnectComplete(int result); 156 int DoTransportConnectComplete(int result);
141 int DoSOCKSConnect(); 157 int DoSOCKSConnect();
142 int DoSOCKSConnectComplete(int result); 158 int DoSOCKSConnectComplete(int result);
143 int DoTunnelConnect(); 159 int DoTunnelConnect();
144 int DoTunnelConnectComplete(int result); 160 int DoTunnelConnectComplete(int result);
161 int DoCreateSSLSocket();
162 int DoCheckForResume();
145 int DoSSLConnect(); 163 int DoSSLConnect();
146 int DoSSLConnectComplete(int result); 164 int DoSSLConnectComplete(int result);
147 165
166 // Decides how pending jobs should continue their connection
167 // based upon the success or failure of the leading job.
168 void ProcessPendingJobs(int result);
169
170 // Tells a waiting SSLConnectJob to resume its SSL connection.
171 void ResumeSSLConnection();
172
173 static bool enable_job_waiting_;
Ryan Sleevi 2014/06/25 19:13:21 STYLE: This member variable should be moved to lin
mshelley1 2014/06/25 20:50:28 Done.
174
148 // Returns the initial state for the state machine based on the 175 // Returns the initial state for the state machine based on the
149 // |connection_type|. 176 // |connection_type|.
150 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); 177 static State GetInitialState(SSLSocketParams::ConnectionType connection_type);
151 178
152 // Starts the SSL connection process. Returns OK on success and 179 // Starts the SSL connection process. Returns OK on success and
153 // ERR_IO_PENDING if it cannot immediately service the request. 180 // ERR_IO_PENDING if it cannot immediately service the request.
154 // Otherwise, it returns a net error code. 181 // Otherwise, it returns a net error code.
155 virtual int ConnectInternal() OVERRIDE; 182 virtual int ConnectInternal() OVERRIDE;
156 183
157 scoped_refptr<SSLSocketParams> params_; 184 scoped_refptr<SSLSocketParams> params_;
158 TransportClientSocketPool* const transport_pool_; 185 TransportClientSocketPool* const transport_pool_;
159 SOCKSClientSocketPool* const socks_pool_; 186 SOCKSClientSocketPool* const socks_pool_;
160 HttpProxyClientSocketPool* const http_proxy_pool_; 187 HttpProxyClientSocketPool* const http_proxy_pool_;
161 ClientSocketFactory* const client_socket_factory_; 188 ClientSocketFactory* const client_socket_factory_;
162 HostResolver* const host_resolver_; 189 HostResolver* const host_resolver_;
163 190
164 const SSLClientSocketContext context_; 191 const SSLClientSocketContext context_;
165 192
166 State next_state_; 193 State next_state_;
167 CompletionCallback callback_; 194 CompletionCallback io_callback_;
168 scoped_ptr<ClientSocketHandle> transport_socket_handle_; 195 scoped_ptr<ClientSocketHandle> transport_socket_handle_;
169 scoped_ptr<SSLClientSocket> ssl_socket_; 196 scoped_ptr<SSLClientSocket> ssl_socket_;
170 197
198 // TODO(mshelley) ensure that these pointers are deleted.
199 PendingJobList* pending_jobs_;
171 HttpResponseInfo error_response_info_; 200 HttpResponseInfo error_response_info_;
172 201
173 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); 202 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob);
174 }; 203 };
175 204
176 class NET_EXPORT_PRIVATE SSLClientSocketPool 205 class NET_EXPORT_PRIVATE SSLClientSocketPool
177 : public ClientSocketPool, 206 : public ClientSocketPool,
178 public HigherLayeredPool, 207 public HigherLayeredPool,
179 public SSLConfigService::Observer { 208 public SSLConfigService::Observer {
180 public: 209 public:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 306
278 // ClientSocketPoolBase::ConnectJobFactory methods. 307 // ClientSocketPoolBase::ConnectJobFactory methods.
279 virtual scoped_ptr<ConnectJob> NewConnectJob( 308 virtual scoped_ptr<ConnectJob> NewConnectJob(
280 const std::string& group_name, 309 const std::string& group_name,
281 const PoolBase::Request& request, 310 const PoolBase::Request& request,
282 ConnectJob::Delegate* delegate) const OVERRIDE; 311 ConnectJob::Delegate* delegate) const OVERRIDE;
283 312
284 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; 313 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE;
285 314
286 private: 315 private:
316 // Maps SSLConnectJob group names to lists of pending connect jobs to
317 // that group name.
318 typedef std::map<std::string, SSLConnectJob::PendingJobList*> PendingJobMap;
319
287 TransportClientSocketPool* const transport_pool_; 320 TransportClientSocketPool* const transport_pool_;
288 SOCKSClientSocketPool* const socks_pool_; 321 SOCKSClientSocketPool* const socks_pool_;
289 HttpProxyClientSocketPool* const http_proxy_pool_; 322 HttpProxyClientSocketPool* const http_proxy_pool_;
290 ClientSocketFactory* const client_socket_factory_; 323 ClientSocketFactory* const client_socket_factory_;
291 HostResolver* const host_resolver_; 324 HostResolver* const host_resolver_;
292 const SSLClientSocketContext context_; 325 const SSLClientSocketContext context_;
293 base::TimeDelta timeout_; 326 base::TimeDelta timeout_;
294 NetLog* net_log_; 327 NetLog* net_log_;
328 scoped_ptr<PendingJobMap> pending_jobs_map_;
295 329
296 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); 330 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory);
297 }; 331 };
298 332
299 TransportClientSocketPool* const transport_pool_; 333 TransportClientSocketPool* const transport_pool_;
300 SOCKSClientSocketPool* const socks_pool_; 334 SOCKSClientSocketPool* const socks_pool_;
301 HttpProxyClientSocketPool* const http_proxy_pool_; 335 HttpProxyClientSocketPool* const http_proxy_pool_;
302 PoolBase base_; 336 PoolBase base_;
303 const scoped_refptr<SSLConfigService> ssl_config_service_; 337 const scoped_refptr<SSLConfigService> ssl_config_service_;
304 338
305 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); 339 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool);
306 }; 340 };
307 341
308 } // namespace net 342 } // namespace net
309 343
310 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ 344 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698