| 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 #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/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/mock_host_resolver.h" | 14 #include "net/base/mock_host_resolver.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
| 16 #include "net/base/ssl_config_service_defaults.h" | 17 #include "net/base/ssl_config_service_defaults.h" |
| 17 #include "net/http/http_auth_handler_factory.h" | 18 #include "net/http/http_auth_handler_factory.h" |
| 18 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
| 19 #include "net/http/http_request_headers.h" | 20 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 21 #include "net/socket/client_socket_factory.h" | 22 #include "net/socket/client_socket_factory.h" |
| 22 #include "net/socket/client_socket_handle.h" | 23 #include "net/socket/client_socket_handle.h" |
| 23 #include "net/socket/client_socket_pool_histograms.h" | 24 #include "net/socket/client_socket_pool_histograms.h" |
| 24 #include "net/socket/socket_test_util.h" | 25 #include "net/socket/socket_test_util.h" |
| 25 #include "net/spdy/spdy_session_pool.h" | 26 #include "net/spdy/spdy_session_pool.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 namespace net { | 29 namespace net { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const int kMaxSockets = 32; | 33 const int kMaxSockets = 32; |
| 33 const int kMaxSocketsPerGroup = 6; | 34 const int kMaxSocketsPerGroup = 6; |
| 34 | 35 |
| 35 class SSLClientSocketPoolTest : public testing::Test { | 36 class SSLClientSocketPoolTest : public testing::Test { |
| 36 protected: | 37 protected: |
| 37 SSLClientSocketPoolTest() | 38 SSLClientSocketPoolTest() |
| 38 : host_resolver_(new MockHostResolver), | 39 : host_resolver_(new MockHostResolver), |
| 40 cert_verifier_(new CertVerifier), |
| 39 http_auth_handler_factory_(HttpAuthHandlerFactory::CreateDefault( | 41 http_auth_handler_factory_(HttpAuthHandlerFactory::CreateDefault( |
| 40 host_resolver_.get())), | 42 host_resolver_.get())), |
| 41 session_(new HttpNetworkSession(host_resolver_.get(), | 43 session_(new HttpNetworkSession(host_resolver_.get(), |
| 44 cert_verifier_.get(), |
| 42 NULL /* dnsrr_resolver */, | 45 NULL /* dnsrr_resolver */, |
| 43 NULL /* dns_cert_checker */, | 46 NULL /* dns_cert_checker */, |
| 44 NULL /* ssl_host_info_factory */, | 47 NULL /* ssl_host_info_factory */, |
| 45 ProxyService::CreateDirect(), | 48 ProxyService::CreateDirect(), |
| 46 &socket_factory_, | 49 &socket_factory_, |
| 47 new SSLConfigServiceDefaults, | 50 new SSLConfigServiceDefaults, |
| 48 new SpdySessionPool(NULL), | 51 new SpdySessionPool(NULL), |
| 49 http_auth_handler_factory_.get(), | 52 http_auth_handler_factory_.get(), |
| 50 NULL, | 53 NULL, |
| 51 NULL)), | 54 NULL)), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 new SSLConfigServiceDefaults); | 92 new SSLConfigServiceDefaults); |
| 90 ssl_config_service->GetSSLConfig(&ssl_config_); | 93 ssl_config_service->GetSSLConfig(&ssl_config_); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void CreatePool(bool tcp_pool, bool http_proxy_pool, bool socks_pool) { | 96 void CreatePool(bool tcp_pool, bool http_proxy_pool, bool socks_pool) { |
| 94 ssl_histograms_.reset(new ClientSocketPoolHistograms("SSLUnitTest")); | 97 ssl_histograms_.reset(new ClientSocketPoolHistograms("SSLUnitTest")); |
| 95 pool_.reset(new SSLClientSocketPool( | 98 pool_.reset(new SSLClientSocketPool( |
| 96 kMaxSockets, | 99 kMaxSockets, |
| 97 kMaxSocketsPerGroup, | 100 kMaxSocketsPerGroup, |
| 98 ssl_histograms_.get(), | 101 ssl_histograms_.get(), |
| 99 NULL, | 102 NULL /* host_resolver */, |
| 103 NULL /* cert_verifier */, |
| 100 NULL /* dnsrr_resolver */, | 104 NULL /* dnsrr_resolver */, |
| 101 NULL /* dns_cert_checker */, | 105 NULL /* dns_cert_checker */, |
| 102 NULL /* ssl_host_info_factory */, | 106 NULL /* ssl_host_info_factory */, |
| 103 &socket_factory_, | 107 &socket_factory_, |
| 104 tcp_pool ? &tcp_socket_pool_ : NULL, | 108 tcp_pool ? &tcp_socket_pool_ : NULL, |
| 105 socks_pool ? &socks_socket_pool_ : NULL, | 109 socks_pool ? &socks_socket_pool_ : NULL, |
| 106 http_proxy_pool ? &http_proxy_socket_pool_ : NULL, | 110 http_proxy_pool ? &http_proxy_socket_pool_ : NULL, |
| 107 NULL, | 111 NULL, |
| 108 NULL)); | 112 NULL)); |
| 109 } | 113 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 124 | 128 |
| 125 void AddAuthToCache() { | 129 void AddAuthToCache() { |
| 126 const string16 kFoo(ASCIIToUTF16("foo")); | 130 const string16 kFoo(ASCIIToUTF16("foo")); |
| 127 const string16 kBar(ASCIIToUTF16("bar")); | 131 const string16 kBar(ASCIIToUTF16("bar")); |
| 128 session_->auth_cache()->Add(GURL("http://proxy:443/"), "MyRealm1", "Basic", | 132 session_->auth_cache()->Add(GURL("http://proxy:443/"), "MyRealm1", "Basic", |
| 129 "Basic realm=MyRealm1", kFoo, kBar, "/"); | 133 "Basic realm=MyRealm1", kFoo, kBar, "/"); |
| 130 } | 134 } |
| 131 | 135 |
| 132 MockClientSocketFactory socket_factory_; | 136 MockClientSocketFactory socket_factory_; |
| 133 scoped_ptr<HostResolver> host_resolver_; | 137 scoped_ptr<HostResolver> host_resolver_; |
| 138 scoped_ptr<CertVerifier> cert_verifier_; |
| 134 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; | 139 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
| 135 scoped_refptr<HttpNetworkSession> session_; | 140 scoped_refptr<HttpNetworkSession> session_; |
| 136 | 141 |
| 137 scoped_refptr<TCPSocketParams> direct_tcp_socket_params_; | 142 scoped_refptr<TCPSocketParams> direct_tcp_socket_params_; |
| 138 ClientSocketPoolHistograms tcp_histograms_; | 143 ClientSocketPoolHistograms tcp_histograms_; |
| 139 MockTCPClientSocketPool tcp_socket_pool_; | 144 MockTCPClientSocketPool tcp_socket_pool_; |
| 140 | 145 |
| 141 scoped_refptr<TCPSocketParams> proxy_tcp_socket_params_; | 146 scoped_refptr<TCPSocketParams> proxy_tcp_socket_params_; |
| 142 | 147 |
| 143 scoped_refptr<SOCKSSocketParams> socks_socket_params_; | 148 scoped_refptr<SOCKSSocketParams> socks_socket_params_; |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 handle.release_pending_http_proxy_connection()); | 638 handle.release_pending_http_proxy_connection()); |
| 634 EXPECT_TRUE(tunnel_handle->socket()); | 639 EXPECT_TRUE(tunnel_handle->socket()); |
| 635 EXPECT_FALSE(tunnel_handle->socket()->IsConnected()); | 640 EXPECT_FALSE(tunnel_handle->socket()->IsConnected()); |
| 636 } | 641 } |
| 637 | 642 |
| 638 // It would be nice to also test the timeouts in SSLClientSocketPool. | 643 // It would be nice to also test the timeouts in SSLClientSocketPool. |
| 639 | 644 |
| 640 } // namespace | 645 } // namespace |
| 641 | 646 |
| 642 } // namespace net | 647 } // namespace net |
| OLD | NEW |