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