OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "net/base/host_resolver.h" | 14 #include "net/base/host_resolver.h" |
15 #include "net/base/ssl_config_service.h" | 15 #include "net/base/ssl_config_service.h" |
16 #include "net/http/http_response_info.h" | 16 #include "net/http/http_response_info.h" |
17 #include "net/proxy/proxy_server.h" | 17 #include "net/proxy/proxy_server.h" |
18 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
19 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
20 #include "net/socket/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
21 #include "net/socket/client_socket_pool.h" | 21 #include "net/socket/client_socket_pool.h" |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 class ClientSocketFactory; | 25 class ClientSocketFactory; |
26 class ConnectJobFactory; | 26 class ConnectJobFactory; |
| 27 class DnsRRResolver; |
27 class HttpProxyClientSocketPool; | 28 class HttpProxyClientSocketPool; |
28 class HttpProxySocketParams; | 29 class HttpProxySocketParams; |
29 class SOCKSClientSocketPool; | 30 class SOCKSClientSocketPool; |
30 class SOCKSSocketParams; | 31 class SOCKSSocketParams; |
31 class SSLClientSocket; | 32 class SSLClientSocket; |
32 class TCPClientSocketPool; | 33 class TCPClientSocketPool; |
33 class TCPSocketParams; | 34 class TCPSocketParams; |
34 struct RRResponse; | 35 struct RRResponse; |
35 | 36 |
36 // SSLSocketParams only needs the socket params for the transport socket | 37 // SSLSocketParams only needs the socket params for the transport socket |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 public: | 85 public: |
85 SSLConnectJob( | 86 SSLConnectJob( |
86 const std::string& group_name, | 87 const std::string& group_name, |
87 const scoped_refptr<SSLSocketParams>& params, | 88 const scoped_refptr<SSLSocketParams>& params, |
88 const base::TimeDelta& timeout_duration, | 89 const base::TimeDelta& timeout_duration, |
89 TCPClientSocketPool* tcp_pool, | 90 TCPClientSocketPool* tcp_pool, |
90 SOCKSClientSocketPool* socks_pool, | 91 SOCKSClientSocketPool* socks_pool, |
91 HttpProxyClientSocketPool* http_proxy_pool, | 92 HttpProxyClientSocketPool* http_proxy_pool, |
92 ClientSocketFactory* client_socket_factory, | 93 ClientSocketFactory* client_socket_factory, |
93 HostResolver* host_resolver, | 94 HostResolver* host_resolver, |
| 95 DnsRRResolver* dnsrr_resolver, |
94 Delegate* delegate, | 96 Delegate* delegate, |
95 NetLog* net_log); | 97 NetLog* net_log); |
96 virtual ~SSLConnectJob(); | 98 virtual ~SSLConnectJob(); |
97 | 99 |
98 // ConnectJob methods. | 100 // ConnectJob methods. |
99 virtual LoadState GetLoadState() const; | 101 virtual LoadState GetLoadState() const; |
100 | 102 |
101 virtual void GetAdditionalErrorState(ClientSocketHandle * handle); | 103 virtual void GetAdditionalErrorState(ClientSocketHandle * handle); |
102 | 104 |
103 private: | 105 private: |
(...skipping 27 matching lines...) Expand all Loading... |
131 int DoTunnelConnectComplete(int result); | 133 int DoTunnelConnectComplete(int result); |
132 int DoSSLConnect(); | 134 int DoSSLConnect(); |
133 int DoSSLConnectComplete(int result); | 135 int DoSSLConnectComplete(int result); |
134 | 136 |
135 scoped_refptr<SSLSocketParams> params_; | 137 scoped_refptr<SSLSocketParams> params_; |
136 TCPClientSocketPool* const tcp_pool_; | 138 TCPClientSocketPool* const tcp_pool_; |
137 SOCKSClientSocketPool* const socks_pool_; | 139 SOCKSClientSocketPool* const socks_pool_; |
138 HttpProxyClientSocketPool* const http_proxy_pool_; | 140 HttpProxyClientSocketPool* const http_proxy_pool_; |
139 ClientSocketFactory* const client_socket_factory_; | 141 ClientSocketFactory* const client_socket_factory_; |
140 HostResolver* const resolver_; | 142 HostResolver* const resolver_; |
| 143 DnsRRResolver* dnsrr_resolver_; |
141 | 144 |
142 State next_state_; | 145 State next_state_; |
143 CompletionCallbackImpl<SSLConnectJob> callback_; | 146 CompletionCallbackImpl<SSLConnectJob> callback_; |
144 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 147 scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
145 scoped_ptr<SSLClientSocket> ssl_socket_; | 148 scoped_ptr<SSLClientSocket> ssl_socket_; |
146 | 149 |
147 // The time the DoSSLConnect() method was called. | 150 // The time the DoSSLConnect() method was called. |
148 base::TimeTicks ssl_connect_start_time_; | 151 base::TimeTicks ssl_connect_start_time_; |
149 | 152 |
150 HttpResponseInfo error_response_info_; | 153 HttpResponseInfo error_response_info_; |
151 | 154 |
152 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); | 155 DISALLOW_COPY_AND_ASSIGN(SSLConnectJob); |
153 }; | 156 }; |
154 | 157 |
155 class SSLClientSocketPool : public ClientSocketPool, | 158 class SSLClientSocketPool : public ClientSocketPool, |
156 public SSLConfigService::Observer { | 159 public SSLConfigService::Observer { |
157 public: | 160 public: |
158 // Only the pools that will be used are required. i.e. if you never | 161 // Only the pools that will be used are required. i.e. if you never |
159 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. | 162 // try to create an SSL over SOCKS socket, |socks_pool| may be NULL. |
160 SSLClientSocketPool( | 163 SSLClientSocketPool( |
161 int max_sockets, | 164 int max_sockets, |
162 int max_sockets_per_group, | 165 int max_sockets_per_group, |
163 ClientSocketPoolHistograms* histograms, | 166 ClientSocketPoolHistograms* histograms, |
164 HostResolver* host_resolver, | 167 HostResolver* host_resolver, |
| 168 DnsRRResolver* dnsrr_resolver, |
165 ClientSocketFactory* client_socket_factory, | 169 ClientSocketFactory* client_socket_factory, |
166 TCPClientSocketPool* tcp_pool, | 170 TCPClientSocketPool* tcp_pool, |
167 SOCKSClientSocketPool* socks_pool, | 171 SOCKSClientSocketPool* socks_pool, |
168 HttpProxyClientSocketPool* http_proxy_pool, | 172 HttpProxyClientSocketPool* http_proxy_pool, |
169 SSLConfigService* ssl_config_service, | 173 SSLConfigService* ssl_config_service, |
170 NetLog* net_log); | 174 NetLog* net_log); |
171 | 175 |
172 virtual ~SSLClientSocketPool(); | 176 virtual ~SSLClientSocketPool(); |
173 | 177 |
174 // ClientSocketPool methods: | 178 // ClientSocketPool methods: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; | 225 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; |
222 | 226 |
223 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { | 227 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { |
224 public: | 228 public: |
225 SSLConnectJobFactory( | 229 SSLConnectJobFactory( |
226 TCPClientSocketPool* tcp_pool, | 230 TCPClientSocketPool* tcp_pool, |
227 SOCKSClientSocketPool* socks_pool, | 231 SOCKSClientSocketPool* socks_pool, |
228 HttpProxyClientSocketPool* http_proxy_pool, | 232 HttpProxyClientSocketPool* http_proxy_pool, |
229 ClientSocketFactory* client_socket_factory, | 233 ClientSocketFactory* client_socket_factory, |
230 HostResolver* host_resolver, | 234 HostResolver* host_resolver, |
| 235 DnsRRResolver* dnsrr_resolver, |
231 NetLog* net_log); | 236 NetLog* net_log); |
232 | 237 |
233 virtual ~SSLConnectJobFactory() {} | 238 virtual ~SSLConnectJobFactory() {} |
234 | 239 |
235 // ClientSocketPoolBase::ConnectJobFactory methods. | 240 // ClientSocketPoolBase::ConnectJobFactory methods. |
236 virtual ConnectJob* NewConnectJob( | 241 virtual ConnectJob* NewConnectJob( |
237 const std::string& group_name, | 242 const std::string& group_name, |
238 const PoolBase::Request& request, | 243 const PoolBase::Request& request, |
239 ConnectJob::Delegate* delegate) const; | 244 ConnectJob::Delegate* delegate) const; |
240 | 245 |
241 virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } | 246 virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } |
242 | 247 |
243 private: | 248 private: |
244 TCPClientSocketPool* const tcp_pool_; | 249 TCPClientSocketPool* const tcp_pool_; |
245 SOCKSClientSocketPool* const socks_pool_; | 250 SOCKSClientSocketPool* const socks_pool_; |
246 HttpProxyClientSocketPool* const http_proxy_pool_; | 251 HttpProxyClientSocketPool* const http_proxy_pool_; |
247 ClientSocketFactory* const client_socket_factory_; | 252 ClientSocketFactory* const client_socket_factory_; |
248 HostResolver* const host_resolver_; | 253 HostResolver* const host_resolver_; |
| 254 DnsRRResolver* dnsrr_resolver_; |
249 base::TimeDelta timeout_; | 255 base::TimeDelta timeout_; |
250 NetLog* net_log_; | 256 NetLog* net_log_; |
251 | 257 |
252 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); | 258 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); |
253 }; | 259 }; |
254 | 260 |
255 TCPClientSocketPool* const tcp_pool_; | 261 TCPClientSocketPool* const tcp_pool_; |
256 SOCKSClientSocketPool* const socks_pool_; | 262 SOCKSClientSocketPool* const socks_pool_; |
257 HttpProxyClientSocketPool* const http_proxy_pool_; | 263 HttpProxyClientSocketPool* const http_proxy_pool_; |
258 PoolBase base_; | 264 PoolBase base_; |
259 const scoped_refptr<SSLConfigService> ssl_config_service_; | 265 const scoped_refptr<SSLConfigService> ssl_config_service_; |
260 | 266 |
261 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 267 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
262 }; | 268 }; |
263 | 269 |
264 REGISTER_SOCKET_PARAMS_FOR_POOL(SSLClientSocketPool, SSLSocketParams); | 270 REGISTER_SOCKET_PARAMS_FOR_POOL(SSLClientSocketPool, SSLSocketParams); |
265 | 271 |
266 } // namespace net | 272 } // namespace net |
267 | 273 |
268 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 274 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |