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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/proxy_delegate.h" | 15 #include "net/base/proxy_delegate.h" |
16 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
17 #include "net/base/test_proxy_delegate.h" | 17 #include "net/base/test_proxy_delegate.h" |
18 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
19 #include "net/http/http_proxy_client_socket.h" | 19 #include "net/http/http_proxy_client_socket.h" |
20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
21 #include "net/log/net_log_with_source.h" | 21 #include "net/log/net_log_with_source.h" |
22 #include "net/nqe/network_quality_estimator_test_util.h" | |
22 #include "net/socket/client_socket_handle.h" | 23 #include "net/socket/client_socket_handle.h" |
23 #include "net/socket/next_proto.h" | 24 #include "net/socket/next_proto.h" |
24 #include "net/socket/socket_test_util.h" | 25 #include "net/socket/socket_test_util.h" |
25 #include "net/spdy/chromium/spdy_test_util_common.h" | 26 #include "net/spdy/chromium/spdy_test_util_common.h" |
26 #include "net/spdy/core/spdy_protocol.h" | 27 #include "net/spdy/core/spdy_protocol.h" |
27 #include "net/test/gtest_util.h" | 28 #include "net/test/gtest_util.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 using net::test::IsError; | 32 using net::test::IsError; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 session_deps_.socket_factory.get(), | 72 session_deps_.socket_factory.get(), |
72 &transport_socket_pool_, | 73 &transport_socket_pool_, |
73 NULL, | 74 NULL, |
74 NULL, | 75 NULL, |
75 session_deps_.ssl_config_service.get(), | 76 session_deps_.ssl_config_service.get(), |
76 NetLogWithSource().net_log()), | 77 NetLogWithSource().net_log()), |
77 pool_(kMaxSockets, | 78 pool_(kMaxSockets, |
78 kMaxSocketsPerGroup, | 79 kMaxSocketsPerGroup, |
79 &transport_socket_pool_, | 80 &transport_socket_pool_, |
80 &ssl_socket_pool_, | 81 &ssl_socket_pool_, |
82 &estimator_, | |
81 NULL) { | 83 NULL) { |
82 session_ = CreateNetworkSession(); | 84 session_ = CreateNetworkSession(); |
83 } | 85 } |
84 | 86 |
85 virtual ~HttpProxyClientSocketPoolTest() {} | 87 virtual ~HttpProxyClientSocketPoolTest() {} |
86 | 88 |
87 void AddAuthToCache() { | 89 void AddAuthToCache() { |
88 const base::string16 kFoo(base::ASCIIToUTF16("foo")); | 90 const base::string16 kFoo(base::ASCIIToUTF16("foo")); |
89 const base::string16 kBar(base::ASCIIToUTF16("bar")); | 91 const base::string16 kBar(base::ASCIIToUTF16("bar")); |
90 GURL proxy_url(GetParam() == HTTP | 92 GURL proxy_url(GetParam() == HTTP |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 192 |
191 RequestPriority GetLastTransportRequestPriority() const { | 193 RequestPriority GetLastTransportRequestPriority() const { |
192 return transport_socket_pool_.last_request_priority(); | 194 return transport_socket_pool_.last_request_priority(); |
193 } | 195 } |
194 | 196 |
195 const base::HistogramTester& histogram_tester() { return histogram_tester_; } | 197 const base::HistogramTester& histogram_tester() { return histogram_tester_; } |
196 | 198 |
197 private: | 199 private: |
198 SpdySessionDependencies session_deps_; | 200 SpdySessionDependencies session_deps_; |
199 | 201 |
202 TestNetworkQualityEstimator estimator_; | |
203 | |
200 MockTransportClientSocketPool transport_socket_pool_; | 204 MockTransportClientSocketPool transport_socket_pool_; |
201 MockHostResolver host_resolver_; | 205 MockHostResolver host_resolver_; |
202 std::unique_ptr<CertVerifier> cert_verifier_; | 206 std::unique_ptr<CertVerifier> cert_verifier_; |
203 SSLClientSocketPool ssl_socket_pool_; | 207 SSLClientSocketPool ssl_socket_pool_; |
204 | 208 |
205 std::unique_ptr<HttpNetworkSession> session_; | 209 std::unique_ptr<HttpNetworkSession> session_; |
206 | 210 |
207 base::HistogramTester histogram_tester_; | 211 base::HistogramTester histogram_tester_; |
208 | 212 |
209 protected: | 213 protected: |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 // Make sure Content-Length: 0 header was added. | 719 // Make sure Content-Length: 0 header was added. |
716 EXPECT_TRUE(headers->HasHeaderValue("content-length", "0")); | 720 EXPECT_TRUE(headers->HasHeaderValue("content-length", "0")); |
717 | 721 |
718 // Make sure Location header was included and correct. | 722 // Make sure Location header was included and correct. |
719 std::string location; | 723 std::string location; |
720 EXPECT_TRUE(headers->IsRedirect(&location)); | 724 EXPECT_TRUE(headers->IsRedirect(&location)); |
721 EXPECT_EQ(location, redirectTarget); | 725 EXPECT_EQ(location, redirectTarget); |
722 } | 726 } |
723 } | 727 } |
724 | 728 |
729 TEST_P(HttpProxyClientSocketPoolTest, ProxyPoolTimeout) { | |
mmenke
2017/06/07 21:31:26
Hrm...Do we get anything from this? We admittedly
mmenke
2017/06/07 21:31:26
Not sure this really gets us anything. We should
tbansal1
2017/06/08 05:01:50
Acknowledged.
tbansal1
2017/06/08 05:01:50
Well, admittedly the test is very basic, but it ch
mmenke
2017/06/08 17:53:02
Still skeptical, but OK.
| |
730 ASSERT_LE(base::TimeDelta(), pool_.ConnectionTimeout()); | |
731 | |
732 // Test against a large value. | |
733 ASSERT_GE(base::TimeDelta::FromMinutes(10), pool_.ConnectionTimeout()); | |
734 | |
735 #if (defined(OS_ANDROID) || defined(OS_IOS)) | |
736 // On Android and iOS, the timeout is fixed to 10 seconds. | |
737 ASSERT_EQ(base::TimeDelta::FromSeconds(10), pool_.ConnectionTimeout()); | |
738 #endif | |
739 } | |
740 | |
725 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. | 741 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. |
726 | 742 |
727 } // namespace net | 743 } // namespace net |
OLD | NEW |