OLD | NEW |
---|---|
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 <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/thread_task_runner_handle.h" | |
Ryan Sleevi
2014/07/10 00:03:22
This should be in the .cc, not the .h
In .h files
mshelley
2014/07/10 00:44:20
Done.
| |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "net/base/privacy_mode.h" | 17 #include "net/base/privacy_mode.h" |
17 #include "net/dns/host_resolver.h" | 18 #include "net/dns/host_resolver.h" |
18 #include "net/http/http_response_info.h" | 19 #include "net/http/http_response_info.h" |
19 #include "net/socket/client_socket_pool.h" | 20 #include "net/socket/client_socket_pool.h" |
20 #include "net/socket/client_socket_pool_base.h" | 21 #include "net/socket/client_socket_pool_base.h" |
21 #include "net/socket/client_socket_pool_histograms.h" | 22 #include "net/socket/client_socket_pool_histograms.h" |
22 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
23 #include "net/ssl/ssl_config_service.h" | 24 #include "net/ssl/ssl_config_service.h" |
24 | 25 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 SSLClientSocket* socket; | 110 SSLClientSocket* socket; |
110 base::Closure callback; | 111 base::Closure callback; |
111 | 112 |
112 SocketAndCallback(SSLClientSocket* ssl_socket, | 113 SocketAndCallback(SSLClientSocket* ssl_socket, |
113 base::Closure job_resumption_callback) | 114 base::Closure job_resumption_callback) |
114 : socket(ssl_socket), callback(job_resumption_callback) {} | 115 : socket(ssl_socket), callback(job_resumption_callback) {} |
115 }; | 116 }; |
116 | 117 |
117 typedef std::vector<SocketAndCallback> SSLPendingSocketsAndCallbacks; | 118 typedef std::vector<SocketAndCallback> SSLPendingSocketsAndCallbacks; |
118 | 119 |
120 SSLConnectJobMessenger(); | |
121 | |
119 // Returns true if the given |ssl_socket| should continue its | 122 // Returns true if the given |ssl_socket| should continue its |
120 // SSL connection. | 123 // SSL connection. |
121 bool CanProceed(SSLClientSocket* ssl_socket); | 124 bool CanProceed(SSLClientSocket* ssl_socket); |
122 | 125 |
123 // Informs the session cache that it should notify the SSLConnectJobMessenger | 126 // Informs the session cache that it should notify the SSLConnectJobMessenger |
124 // upon the completion of |ssl_socket|'s connection. | 127 // upon the completion of |ssl_socket|'s connection. |
125 void MonitorConnectionResult(SSLClientSocket* ssl_socket); | 128 void MonitorConnectionResult(SSLClientSocket* ssl_socket); |
126 | 129 |
127 // Adds the socket and its associated callback to the SSLConnectJobMessenger's | 130 // Adds the socket and its associated callback to the SSLConnectJobMessenger's |
128 // list of pending sockets and callbacks. | 131 // list of pending sockets and callbacks. |
129 void AddPendingSocket(SSLClientSocket* socket, const base::Closure& callback); | 132 void AddPendingSocket(SSLClientSocket* socket, const base::Closure& callback); |
130 | 133 |
131 // Processes pending callbacks when a socket successfully completes | 134 // Processes pending callbacks when a socket successfully completes |
132 // its connection. | 135 // its connection. |
133 void OnJobSucceeded(); | 136 void OnJobSucceeded(); |
134 | 137 |
135 // Processes pending callbacks when a socket encounters an error | 138 // Posts a task to process pending callbacks when a socket encounters an error |
136 // while completing its connection. | 139 // while completing its connection. |
137 void OnJobFailed(); | 140 void OnJobFailed(); |
138 | 141 |
142 // Determines which pending socket should be then next leading connection, | |
143 // and runs that socket's resumption callback. | |
144 void ConnectNewLeader(); | |
145 | |
139 private: | 146 private: |
140 // Runs all callbacks stored in |pending_sockets_and_callbacks_|. | 147 // Runs all callbacks stored in |pending_sockets_and_callbacks_|. |
141 void RunAllJobs(std::vector<SocketAndCallback>& pending_socket_and_callbacks); | 148 void RunAllJobs( |
149 std::vector<SocketAndCallback>& pending_sockets_and_callbacks); | |
142 | 150 |
151 base::WeakPtrFactory<SSLConnectJobMessenger> weak_factory_; | |
143 SSLPendingSocketsAndCallbacks pending_sockets_and_callbacks_; | 152 SSLPendingSocketsAndCallbacks pending_sockets_and_callbacks_; |
144 std::vector<SSLClientSocket*> connecting_sockets_; | 153 std::vector<SSLClientSocket*> connecting_sockets_; |
145 }; | 154 }; |
146 | 155 |
147 // SSLConnectJob handles the SSL handshake after setting up the underlying | 156 // SSLConnectJob handles the SSL handshake after setting up the underlying |
148 // connection as specified in the params. | 157 // connection as specified in the params. |
149 class SSLConnectJob : public ConnectJob { | 158 class SSLConnectJob : public ConnectJob { |
150 public: | 159 public: |
151 // Note: the SSLConnectJob does not own |messenger|. | 160 // Note: the SSLConnectJob does not own |messenger|. |
152 // so it must outlive the job. | 161 // so it must outlive the job. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 HttpProxyClientSocketPool* const http_proxy_pool_; | 376 HttpProxyClientSocketPool* const http_proxy_pool_; |
368 PoolBase base_; | 377 PoolBase base_; |
369 const scoped_refptr<SSLConfigService> ssl_config_service_; | 378 const scoped_refptr<SSLConfigService> ssl_config_service_; |
370 | 379 |
371 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 380 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
372 }; | 381 }; |
373 | 382 |
374 } // namespace net | 383 } // namespace net |
375 | 384 |
376 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 385 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |