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

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: Added a command line flag that enables my changes. 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 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"
19 #include "net/socket/ssl_client_socket.h" 21 #include "net/socket/ssl_client_socket.h"
22 #include "net/socket/ssl_client_socket_openssl.h"
20 #include "net/ssl/ssl_config_service.h" 23 #include "net/ssl/ssl_config_service.h"
21 24
22 namespace net { 25 namespace net {
23 26
24 class CertVerifier; 27 class CertVerifier;
25 class ClientSocketFactory; 28 class ClientSocketFactory;
26 class ConnectJobFactory; 29 class ConnectJobFactory;
27 class CTVerifier; 30 class CTVerifier;
28 class HostPortPair; 31 class HostPortPair;
29 class HttpProxyClientSocketPool; 32 class HttpProxyClientSocketPool;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const bool want_spdy_over_npn_; 94 const bool want_spdy_over_npn_;
92 bool ignore_limits_; 95 bool ignore_limits_;
93 96
94 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams); 97 DISALLOW_COPY_AND_ASSIGN(SSLSocketParams);
95 }; 98 };
96 99
97 // SSLConnectJob handles the SSL handshake after setting up the underlying 100 // SSLConnectJob handles the SSL handshake after setting up the underlying
98 // connection as specified in the params. 101 // connection as specified in the params.
99 class SSLConnectJob : public ConnectJob { 102 class SSLConnectJob : public ConnectJob {
100 public: 103 public:
101 SSLConnectJob( 104 typedef std::vector<SSLConnectJob*> PendingJobList;
102 const std::string& group_name, 105 SSLConnectJob(const std::string& group_name,
Ryan Sleevi 2014/06/13 23:24:22 New line before the constructor
mshelley1 2014/06/16 19:02:50 Done.
103 RequestPriority priority, 106 RequestPriority priority,
104 const scoped_refptr<SSLSocketParams>& params, 107 const scoped_refptr<SSLSocketParams>& params,
105 const base::TimeDelta& timeout_duration, 108 const base::TimeDelta& timeout_duration,
106 TransportClientSocketPool* transport_pool, 109 TransportClientSocketPool* transport_pool,
107 SOCKSClientSocketPool* socks_pool, 110 SOCKSClientSocketPool* socks_pool,
108 HttpProxyClientSocketPool* http_proxy_pool, 111 HttpProxyClientSocketPool* http_proxy_pool,
109 ClientSocketFactory* client_socket_factory, 112 ClientSocketFactory* client_socket_factory,
110 HostResolver* host_resolver, 113 HostResolver* host_resolver,
111 const SSLClientSocketContext& context, 114 const SSLClientSocketContext& context,
112 Delegate* delegate, 115 Delegate* delegate,
113 NetLog* net_log); 116 NetLog* net_log,
117 PendingJobList* pending);
114 virtual ~SSLConnectJob(); 118 virtual ~SSLConnectJob();
115 119
120 static bool enable_job_waiting_;
wtc 2014/06/13 22:47:24 This (static) data member should be private.
mshelley1 2014/06/16 19:02:50 Done.
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 static NET_EXPORT void EnableJobWaiting(bool enable);
128
121 private: 129 private:
122 enum State { 130 enum State {
123 STATE_TRANSPORT_CONNECT, 131 STATE_TRANSPORT_CONNECT,
124 STATE_TRANSPORT_CONNECT_COMPLETE, 132 STATE_TRANSPORT_CONNECT_COMPLETE,
125 STATE_SOCKS_CONNECT, 133 STATE_SOCKS_CONNECT,
126 STATE_SOCKS_CONNECT_COMPLETE, 134 STATE_SOCKS_CONNECT_COMPLETE,
127 STATE_TUNNEL_CONNECT, 135 STATE_TUNNEL_CONNECT,
128 STATE_TUNNEL_CONNECT_COMPLETE, 136 STATE_TUNNEL_CONNECT_COMPLETE,
137 STATE_CHECK_FOR_RESUME,
138 STATE_WAIT,
wtc 2014/06/13 22:47:24 Nit: this state's name should be more informative.
mshelley1 2014/06/16 19:02:50 Done.
129 STATE_SSL_CONNECT, 139 STATE_SSL_CONNECT,
130 STATE_SSL_CONNECT_COMPLETE, 140 STATE_SSL_CONNECT_COMPLETE,
131 STATE_NONE, 141 STATE_NONE,
132 }; 142 };
133 143
134 void OnIOComplete(int result); 144 void OnIOComplete(int result);
135 145
136 // Runs the state transition loop. 146 // Runs the state transition loop.
137 int DoLoop(int result); 147 int DoLoop(int result);
138 148
139 int DoTransportConnect(); 149 int DoTransportConnect();
140 int DoTransportConnectComplete(int result); 150 int DoTransportConnectComplete(int result);
141 int DoSOCKSConnect(); 151 int DoSOCKSConnect();
142 int DoSOCKSConnectComplete(int result); 152 int DoSOCKSConnectComplete(int result);
143 int DoTunnelConnect(); 153 int DoTunnelConnect();
144 int DoTunnelConnectComplete(int result); 154 int DoTunnelConnectComplete(int result);
155 int DoCheckForResume();
145 int DoSSLConnect(); 156 int DoSSLConnect();
146 int DoSSLConnectComplete(int result); 157 int DoSSLConnectComplete(int result);
147 158
159 void DoSSL();
Ryan Sleevi 2014/06/13 23:24:22 First reaction: This needs a better (more descript
mshelley1 2014/06/16 19:02:50 Done.
160
161 std::string GetSessionCacheKey();
162
148 // Returns the initial state for the state machine based on the 163 // Returns the initial state for the state machine based on the
149 // |connection_type|. 164 // |connection_type|.
150 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); 165 static State GetInitialState(SSLSocketParams::ConnectionType connection_type);
151 166
152 // Starts the SSL connection process. Returns OK on success and 167 // Starts the SSL connection process. Returns OK on success and
153 // ERR_IO_PENDING if it cannot immediately service the request. 168 // ERR_IO_PENDING if it cannot immediately service the request.
154 // Otherwise, it returns a net error code. 169 // Otherwise, it returns a net error code.
155 virtual int ConnectInternal() OVERRIDE; 170 virtual int ConnectInternal() OVERRIDE;
156 171
157 scoped_refptr<SSLSocketParams> params_; 172 scoped_refptr<SSLSocketParams> params_;
158 TransportClientSocketPool* const transport_pool_; 173 TransportClientSocketPool* const transport_pool_;
159 SOCKSClientSocketPool* const socks_pool_; 174 SOCKSClientSocketPool* const socks_pool_;
160 HttpProxyClientSocketPool* const http_proxy_pool_; 175 HttpProxyClientSocketPool* const http_proxy_pool_;
161 ClientSocketFactory* const client_socket_factory_; 176 ClientSocketFactory* const client_socket_factory_;
162 HostResolver* const host_resolver_; 177 HostResolver* const host_resolver_;
163 178
164 const SSLClientSocketContext context_; 179 const SSLClientSocketContext context_;
165 180
166 State next_state_; 181 State next_state_;
167 CompletionCallback callback_; 182 CompletionCallback callback_;
168 scoped_ptr<ClientSocketHandle> transport_socket_handle_; 183 scoped_ptr<ClientSocketHandle> transport_socket_handle_;
169 scoped_ptr<SSLClientSocket> ssl_socket_; 184 scoped_ptr<SSLClientSocket> ssl_socket_;
170 185
186 PendingJobList* pending_;
wtc 2014/06/13 22:47:24 Rename this member pending_job_list_ or pending_jo
mshelley1 2014/06/16 19:02:50 Done.
171 HttpResponseInfo error_response_info_; 187 HttpResponseInfo error_response_info_;
172 188
173 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); 189 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob);
174 }; 190 };
175 191
176 class NET_EXPORT_PRIVATE SSLClientSocketPool 192 class NET_EXPORT_PRIVATE SSLClientSocketPool
177 : public ClientSocketPool, 193 : public ClientSocketPool,
178 public HigherLayeredPool, 194 public HigherLayeredPool,
179 public SSLConfigService::Observer { 195 public SSLConfigService::Observer {
180 public: 196 public:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; 273 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase;
258 274
259 // SSLConfigService::Observer implementation. 275 // SSLConfigService::Observer implementation.
260 276
261 // When the user changes the SSL config, we flush all idle sockets so they 277 // When the user changes the SSL config, we flush all idle sockets so they
262 // won't get re-used. 278 // won't get re-used.
263 virtual void OnSSLConfigChanged() OVERRIDE; 279 virtual void OnSSLConfigChanged() OVERRIDE;
264 280
265 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { 281 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory {
266 public: 282 public:
283 typedef std::map<std::string, SSLConnectJob::PendingJobList*> PendingJobMap;
Ryan Sleevi 2014/06/13 23:24:22 You don't need to make this typedef public, becaus
mshelley1 2014/06/16 19:02:50 Done.
284
267 SSLConnectJobFactory( 285 SSLConnectJobFactory(
268 TransportClientSocketPool* transport_pool, 286 TransportClientSocketPool* transport_pool,
269 SOCKSClientSocketPool* socks_pool, 287 SOCKSClientSocketPool* socks_pool,
270 HttpProxyClientSocketPool* http_proxy_pool, 288 HttpProxyClientSocketPool* http_proxy_pool,
271 ClientSocketFactory* client_socket_factory, 289 ClientSocketFactory* client_socket_factory,
272 HostResolver* host_resolver, 290 HostResolver* host_resolver,
273 const SSLClientSocketContext& context, 291 const SSLClientSocketContext& context,
274 NetLog* net_log); 292 NetLog* net_log);
275 293
276 virtual ~SSLConnectJobFactory() {} 294 virtual ~SSLConnectJobFactory() {}
277 295
278 // ClientSocketPoolBase::ConnectJobFactory methods. 296 // ClientSocketPoolBase::ConnectJobFactory methods.
279 virtual scoped_ptr<ConnectJob> NewConnectJob( 297 virtual scoped_ptr<ConnectJob> NewConnectJob(
280 const std::string& group_name, 298 const std::string& group_name,
281 const PoolBase::Request& request, 299 const PoolBase::Request& request,
282 ConnectJob::Delegate* delegate) const OVERRIDE; 300 ConnectJob::Delegate* delegate) const OVERRIDE;
283 301
284 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; 302 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE;
285 303
286 private: 304 private:
287 TransportClientSocketPool* const transport_pool_; 305 TransportClientSocketPool* const transport_pool_;
288 SOCKSClientSocketPool* const socks_pool_; 306 SOCKSClientSocketPool* const socks_pool_;
289 HttpProxyClientSocketPool* const http_proxy_pool_; 307 HttpProxyClientSocketPool* const http_proxy_pool_;
290 ClientSocketFactory* const client_socket_factory_; 308 ClientSocketFactory* const client_socket_factory_;
291 HostResolver* const host_resolver_; 309 HostResolver* const host_resolver_;
292 const SSLClientSocketContext context_; 310 const SSLClientSocketContext context_;
293 base::TimeDelta timeout_; 311 base::TimeDelta timeout_;
294 NetLog* net_log_; 312 NetLog* net_log_;
313 PendingJobMap* pending_;
295 314
296 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); 315 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory);
297 }; 316 };
298 317
299 TransportClientSocketPool* const transport_pool_; 318 TransportClientSocketPool* const transport_pool_;
300 SOCKSClientSocketPool* const socks_pool_; 319 SOCKSClientSocketPool* const socks_pool_;
301 HttpProxyClientSocketPool* const http_proxy_pool_; 320 HttpProxyClientSocketPool* const http_proxy_pool_;
302 PoolBase base_; 321 PoolBase base_;
303 const scoped_refptr<SSLConfigService> ssl_config_service_; 322 const scoped_refptr<SSLConfigService> ssl_config_service_;
304 323
305 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); 324 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool);
306 }; 325 };
307 326
308 } // namespace net 327 } // namespace net
309 328
310 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ 329 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698