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 #include "net/http/http_proxy_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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/base/proxy_delegate.h" | 12 #include "net/base/proxy_delegate.h" |
13 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
14 #include "net/http/http_network_session.h" | 14 #include "net/http/http_network_session.h" |
15 #include "net/http/http_proxy_client_socket.h" | 15 #include "net/http/http_proxy_client_socket.h" |
16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
17 #include "net/socket/client_socket_handle.h" | 17 #include "net/socket/client_socket_handle.h" |
18 #include "net/socket/client_socket_pool_histograms.h" | |
19 #include "net/socket/next_proto.h" | 18 #include "net/socket/next_proto.h" |
20 #include "net/socket/socket_test_util.h" | 19 #include "net/socket/socket_test_util.h" |
21 #include "net/spdy/spdy_protocol.h" | 20 #include "net/spdy/spdy_protocol.h" |
22 #include "net/spdy/spdy_test_util_common.h" | 21 #include "net/spdy/spdy_test_util_common.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 | 23 |
25 namespace net { | 24 namespace net { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 HostPortPair on_tunnel_headers_received_proxy_server_; | 148 HostPortPair on_tunnel_headers_received_proxy_server_; |
150 std::string on_tunnel_headers_received_status_line_; | 149 std::string on_tunnel_headers_received_status_line_; |
151 }; | 150 }; |
152 | 151 |
153 | 152 |
154 class HttpProxyClientSocketPoolTest | 153 class HttpProxyClientSocketPoolTest |
155 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> { | 154 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> { |
156 protected: | 155 protected: |
157 HttpProxyClientSocketPoolTest() | 156 HttpProxyClientSocketPoolTest() |
158 : session_deps_(GetParam().protocol), | 157 : session_deps_(GetParam().protocol), |
159 tcp_histograms_("MockTCP"), | |
160 transport_socket_pool_( | 158 transport_socket_pool_( |
161 kMaxSockets, | 159 kMaxSockets, |
162 kMaxSocketsPerGroup, | 160 kMaxSocketsPerGroup, |
163 &tcp_histograms_, | |
164 session_deps_.deterministic_socket_factory.get()), | 161 session_deps_.deterministic_socket_factory.get()), |
165 ssl_histograms_("MockSSL"), | |
166 ssl_socket_pool_(kMaxSockets, | 162 ssl_socket_pool_(kMaxSockets, |
167 kMaxSocketsPerGroup, | 163 kMaxSocketsPerGroup, |
168 &ssl_histograms_, | |
169 session_deps_.cert_verifier.get(), | 164 session_deps_.cert_verifier.get(), |
170 NULL /* channel_id_store */, | 165 NULL /* channel_id_store */, |
171 NULL /* transport_security_state */, | 166 NULL /* transport_security_state */, |
172 NULL /* cert_transparency_verifier */, | 167 NULL /* cert_transparency_verifier */, |
173 NULL /* cert_policy_enforcer */, | 168 NULL /* cert_policy_enforcer */, |
174 std::string() /* ssl_session_cache_shard */, | 169 std::string() /* ssl_session_cache_shard */, |
175 session_deps_.deterministic_socket_factory.get(), | 170 session_deps_.deterministic_socket_factory.get(), |
176 &transport_socket_pool_, | 171 &transport_socket_pool_, |
177 NULL, | 172 NULL, |
178 NULL, | 173 NULL, |
179 session_deps_.ssl_config_service.get(), | 174 session_deps_.ssl_config_service.get(), |
180 BoundNetLog().net_log()), | 175 BoundNetLog().net_log()), |
181 session_(CreateNetworkSession()), | 176 session_(CreateNetworkSession()), |
182 http_proxy_histograms_("HttpProxyUnitTest"), | |
183 spdy_util_(GetParam().protocol), | 177 spdy_util_(GetParam().protocol), |
184 pool_(kMaxSockets, | 178 pool_(kMaxSockets, |
185 kMaxSocketsPerGroup, | 179 kMaxSocketsPerGroup, |
186 &http_proxy_histograms_, | |
187 &transport_socket_pool_, | 180 &transport_socket_pool_, |
188 &ssl_socket_pool_, | 181 &ssl_socket_pool_, |
189 NULL) {} | 182 NULL) {} |
190 | 183 |
191 virtual ~HttpProxyClientSocketPoolTest() { | 184 virtual ~HttpProxyClientSocketPoolTest() { |
192 } | 185 } |
193 | 186 |
194 void AddAuthToCache() { | 187 void AddAuthToCache() { |
195 const base::string16 kFoo(base::ASCIIToUTF16("foo")); | 188 const base::string16 kFoo(base::ASCIIToUTF16("foo")); |
196 const base::string16 kBar(base::ASCIIToUTF16("bar")); | 189 const base::string16 kBar(base::ASCIIToUTF16("bar")); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 &session_deps_); | 296 &session_deps_); |
304 } | 297 } |
305 | 298 |
306 RequestPriority GetLastTransportRequestPriority() const { | 299 RequestPriority GetLastTransportRequestPriority() const { |
307 return transport_socket_pool_.last_request_priority(); | 300 return transport_socket_pool_.last_request_priority(); |
308 } | 301 } |
309 | 302 |
310 private: | 303 private: |
311 SpdySessionDependencies session_deps_; | 304 SpdySessionDependencies session_deps_; |
312 | 305 |
313 ClientSocketPoolHistograms tcp_histograms_; | |
314 MockTransportClientSocketPool transport_socket_pool_; | 306 MockTransportClientSocketPool transport_socket_pool_; |
315 ClientSocketPoolHistograms ssl_histograms_; | |
316 MockHostResolver host_resolver_; | 307 MockHostResolver host_resolver_; |
317 scoped_ptr<CertVerifier> cert_verifier_; | 308 scoped_ptr<CertVerifier> cert_verifier_; |
318 SSLClientSocketPool ssl_socket_pool_; | 309 SSLClientSocketPool ssl_socket_pool_; |
319 | 310 |
320 const scoped_refptr<HttpNetworkSession> session_; | 311 const scoped_refptr<HttpNetworkSession> session_; |
321 ClientSocketPoolHistograms http_proxy_histograms_; | |
322 | 312 |
323 protected: | 313 protected: |
324 SpdyTestUtil spdy_util_; | 314 SpdyTestUtil spdy_util_; |
325 scoped_ptr<SSLSocketDataProvider> ssl_data_; | 315 scoped_ptr<SSLSocketDataProvider> ssl_data_; |
326 scoped_ptr<DeterministicSocketData> data_; | 316 scoped_ptr<DeterministicSocketData> data_; |
327 HttpProxyClientSocketPool pool_; | 317 HttpProxyClientSocketPool pool_; |
328 ClientSocketHandle handle_; | 318 ClientSocketHandle handle_; |
329 TestCompletionCallback callback_; | 319 TestCompletionCallback callback_; |
330 }; | 320 }; |
331 | 321 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 EXPECT_TRUE(headers->IsRedirect(&location)); | 830 EXPECT_TRUE(headers->IsRedirect(&location)); |
841 EXPECT_EQ(location, redirectTarget); | 831 EXPECT_EQ(location, redirectTarget); |
842 } | 832 } |
843 } | 833 } |
844 | 834 |
845 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. | 835 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. |
846 | 836 |
847 } // namespace | 837 } // namespace |
848 | 838 |
849 } // namespace net | 839 } // namespace net |
OLD | NEW |