OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "net/socket/ssl_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "net/base/auth.h" | 12 #include "net/base/auth.h" |
13 #include "net/base/cert_verifier.h" | 13 #include "net/base/cert_verifier.h" |
14 #include "net/base/mock_host_resolver.h" | 14 #include "net/base/mock_host_resolver.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/ssl_config_service_defaults.h" | 16 #include "net/base/ssl_config_service_defaults.h" |
17 #include "net/base/sys_addrinfo.h" | 17 #include "net/base/sys_addrinfo.h" |
18 #include "net/base/test_certificate_data.h" | 18 #include "net/base/test_certificate_data.h" |
19 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
20 #include "net/http/http_auth_handler_factory.h" | 20 #include "net/http/http_auth_handler_factory.h" |
21 #include "net/http/http_network_session.h" | 21 #include "net/http/http_network_session.h" |
22 #include "net/http/http_proxy_client_socket_pool.h" | |
23 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
24 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
25 #include "net/http/http_server_properties_impl.h" | 24 #include "net/http/http_server_properties_impl.h" |
26 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
27 #include "net/socket/client_socket_handle.h" | 26 #include "net/socket/client_socket_handle.h" |
28 #include "net/socket/client_socket_pool_histograms.h" | 27 #include "net/socket/client_socket_pool_histograms.h" |
29 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
30 #include "net/spdy/spdy_session.h" | 29 #include "net/spdy/spdy_session.h" |
31 #include "net/spdy/spdy_session_pool.h" | 30 #include "net/spdy/spdy_session_pool.h" |
32 #include "net/spdy/spdy_test_util.h" | 31 #include "net/spdy/spdy_test_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 kMaxSockets, | 64 kMaxSockets, |
66 kMaxSocketsPerGroup, | 65 kMaxSocketsPerGroup, |
67 &socks_histograms_, | 66 &socks_histograms_, |
68 &transport_socket_pool_), | 67 &transport_socket_pool_), |
69 http_proxy_socket_params_(new HttpProxySocketParams( | 68 http_proxy_socket_params_(new HttpProxySocketParams( |
70 proxy_transport_socket_params_, NULL, GURL("http://host"), "", | 69 proxy_transport_socket_params_, NULL, GURL("http://host"), "", |
71 HostPortPair("host", 80), | 70 HostPortPair("host", 80), |
72 session_->http_auth_cache(), | 71 session_->http_auth_cache(), |
73 session_->http_auth_handler_factory(), | 72 session_->http_auth_handler_factory(), |
74 session_->spdy_session_pool(), | 73 session_->spdy_session_pool(), |
75 true, | 74 true)), |
76 base::Bind(&SSLClientSocketPoolTest::OnNeedsProxyAuthCallback, | |
77 base::Unretained(this)))), | |
78 http_proxy_histograms_("MockHttpProxy"), | 75 http_proxy_histograms_("MockHttpProxy"), |
79 http_proxy_socket_pool_( | 76 http_proxy_socket_pool_( |
80 kMaxSockets, | 77 kMaxSockets, |
81 kMaxSocketsPerGroup, | 78 kMaxSocketsPerGroup, |
82 &http_proxy_histograms_, | 79 &http_proxy_histograms_, |
83 &host_resolver_, | 80 &host_resolver_, |
84 &transport_socket_pool_, | 81 &transport_socket_pool_, |
85 NULL, | 82 NULL, |
86 NULL) { | 83 NULL) { |
87 scoped_refptr<SSLConfigService> ssl_config_service( | 84 scoped_refptr<SSLConfigService> ssl_config_service( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 params.host_resolver = &host_resolver_; | 137 params.host_resolver = &host_resolver_; |
141 params.cert_verifier = &cert_verifier_; | 138 params.cert_verifier = &cert_verifier_; |
142 params.proxy_service = proxy_service_.get(); | 139 params.proxy_service = proxy_service_.get(); |
143 params.client_socket_factory = &socket_factory_; | 140 params.client_socket_factory = &socket_factory_; |
144 params.ssl_config_service = ssl_config_service_; | 141 params.ssl_config_service = ssl_config_service_; |
145 params.http_auth_handler_factory = http_auth_handler_factory_.get(); | 142 params.http_auth_handler_factory = http_auth_handler_factory_.get(); |
146 params.http_server_properties = &http_server_properties_; | 143 params.http_server_properties = &http_server_properties_; |
147 return new HttpNetworkSession(params); | 144 return new HttpNetworkSession(params); |
148 } | 145 } |
149 | 146 |
150 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | |
151 HttpAuthController* auth_controller, | |
152 CompletionCallback cb) { | |
153 // Don't add any auth, just execute the callback. | |
154 cb.Run(OK); | |
155 } | |
156 | |
157 MockClientSocketFactory socket_factory_; | 147 MockClientSocketFactory socket_factory_; |
158 MockCachingHostResolver host_resolver_; | 148 MockCachingHostResolver host_resolver_; |
159 CertVerifier cert_verifier_; | 149 CertVerifier cert_verifier_; |
160 const scoped_ptr<ProxyService> proxy_service_; | 150 const scoped_ptr<ProxyService> proxy_service_; |
161 const scoped_refptr<SSLConfigService> ssl_config_service_; | 151 const scoped_refptr<SSLConfigService> ssl_config_service_; |
162 const scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; | 152 const scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
163 HttpServerPropertiesImpl http_server_properties_; | 153 HttpServerPropertiesImpl http_server_properties_; |
164 const scoped_refptr<HttpNetworkSession> session_; | 154 const scoped_refptr<HttpNetworkSession> session_; |
165 | 155 |
166 scoped_refptr<TransportSocketParams> direct_transport_socket_params_; | 156 scoped_refptr<TransportSocketParams> direct_transport_socket_params_; |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); | 831 EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].pair)); |
842 | 832 |
843 session_->spdy_session_pool()->CloseAllSessions(); | 833 session_->spdy_session_pool()->CloseAllSessions(); |
844 } | 834 } |
845 | 835 |
846 // It would be nice to also test the timeouts in SSLClientSocketPool. | 836 // It would be nice to also test the timeouts in SSLClientSocketPool. |
847 | 837 |
848 } // namespace | 838 } // namespace |
849 | 839 |
850 } // namespace net | 840 } // namespace net |
OLD | NEW |