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

Side by Side Diff: net/socket/ssl_client_socket_pool.h

Issue 364943002: Makes waiting SSLConnectJobs use the message loops to resume their connection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed handling of on JobFailed. 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 <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/thread_task_runner_handle.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "net/base/privacy_mode.h" 16 #include "net/base/privacy_mode.h"
16 #include "net/dns/host_resolver.h" 17 #include "net/dns/host_resolver.h"
17 #include "net/http/http_response_info.h" 18 #include "net/http/http_response_info.h"
18 #include "net/socket/client_socket_pool.h" 19 #include "net/socket/client_socket_pool.h"
19 #include "net/socket/client_socket_pool_base.h" 20 #include "net/socket/client_socket_pool_base.h"
20 #include "net/socket/client_socket_pool_histograms.h" 21 #include "net/socket/client_socket_pool_histograms.h"
21 #include "net/socket/ssl_client_socket.h" 22 #include "net/socket/ssl_client_socket.h"
22 #include "net/ssl/ssl_config_service.h" 23 #include "net/ssl/ssl_config_service.h"
23 24
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 SocketAndCallback(SSLClientSocket* ssl_socket, 109 SocketAndCallback(SSLClientSocket* ssl_socket,
109 base::Closure job_resumption_callback) 110 base::Closure job_resumption_callback)
110 : socket(ssl_socket), callback(job_resumption_callback) {} 111 : socket(ssl_socket), callback(job_resumption_callback) {}
111 112
112 SSLClientSocket* socket; 113 SSLClientSocket* socket;
113 base::Closure callback; 114 base::Closure callback;
114 }; 115 };
115 116
116 typedef std::vector<SocketAndCallback> SSLPendingSocketsAndCallbacks; 117 typedef std::vector<SocketAndCallback> SSLPendingSocketsAndCallbacks;
117 118
119 SSLConnectJobMessenger();
120
118 // Removes |socket| from |connecting_sockets_| or 121 // Removes |socket| from |connecting_sockets_| or
119 // |pending_sockets_and_callbacks_| 122 // |pending_sockets_and_callbacks_|
120 // if it is present in either. 123 // if it is present in either.
121 void RemoveSocket(SSLClientSocket* ssl_socket); 124 void RemoveSocket(SSLClientSocket* ssl_socket);
122 125
123 // Returns true if |ssl_socket|'s Connect() method should be called. 126 // Returns true if |ssl_socket|'s Connect() method should be called.
124 bool CanProceed(SSLClientSocket* ssl_socket); 127 bool CanProceed(SSLClientSocket* ssl_socket);
125 128
126 // Configure the SSLConnectJobMessenger to begin monitoring |ssl_socket|'s 129 // Configure the SSLConnectJobMessenger to begin monitoring |ssl_socket|'s
127 // connection status. After a successful connection, or an error, 130 // connection status. After a successful connection, or an error,
(...skipping 22 matching lines...) Expand all
150 void OnJobFailed(); 153 void OnJobFailed();
151 154
152 // Runs all callbacks stored in |pending_sockets_and_callbacks_|. 155 // Runs all callbacks stored in |pending_sockets_and_callbacks_|.
153 void RunAllCallbacks( 156 void RunAllCallbacks(
154 const SSLPendingSocketsAndCallbacks& pending_socket_and_callbacks); 157 const SSLPendingSocketsAndCallbacks& pending_socket_and_callbacks);
155 158
156 SSLPendingSocketsAndCallbacks pending_sockets_and_callbacks_; 159 SSLPendingSocketsAndCallbacks pending_sockets_and_callbacks_;
157 // Note: this field is a vector to allow for future design changes. Currently, 160 // Note: this field is a vector to allow for future design changes. Currently,
158 // this vector should only ever have one entry. 161 // this vector should only ever have one entry.
159 std::vector<SSLClientSocket*> connecting_sockets_; 162 std::vector<SSLClientSocket*> connecting_sockets_;
163
164 base::WeakPtrFactory<SSLConnectJobMessenger> weak_factory_;
160 }; 165 };
161 166
162 // SSLConnectJob handles the SSL handshake after setting up the underlying 167 // SSLConnectJob handles the SSL handshake after setting up the underlying
163 // connection as specified in the params. 168 // connection as specified in the params.
164 class SSLConnectJob : public ConnectJob { 169 class SSLConnectJob : public ConnectJob {
165 public: 170 public:
166 // Note: the SSLConnectJob does not own |messenger|. 171 // Note: the SSLConnectJob does not own |messenger|.
167 // so it must outlive the job. 172 // so it must outlive the job.
168 SSLConnectJob(const std::string& group_name, 173 SSLConnectJob(const std::string& group_name,
169 RequestPriority priority, 174 RequestPriority priority,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 const scoped_refptr<SSLConfigService> ssl_config_service_; 394 const scoped_refptr<SSLConfigService> ssl_config_service_;
390 395
391 static bool enable_connect_job_waiting_; 396 static bool enable_connect_job_waiting_;
392 397
393 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); 398 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool);
394 }; 399 };
395 400
396 } // namespace net 401 } // namespace net
397 402
398 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ 403 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698