Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: net/socket/ssl_client_socket_pool_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 ExpectConnectTimingHasTimes(load_timing_info.connect_timing, 72 ExpectConnectTimingHasTimes(load_timing_info.connect_timing,
73 CONNECT_TIMING_HAS_SSL_TIMES); 73 CONNECT_TIMING_HAS_SSL_TIMES);
74 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); 74 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info);
75 } 75 }
76 76
77 class SSLClientSocketPoolTest : public testing::Test { 77 class SSLClientSocketPoolTest : public testing::Test {
78 protected: 78 protected:
79 SSLClientSocketPoolTest() 79 SSLClientSocketPoolTest()
80 : proxy_service_(ProxyService::CreateDirect()), 80 : proxy_service_(ProxyService::CreateDirect()),
81 ssl_config_service_(new SSLConfigServiceDefaults), 81 ssl_config_service_(new SSLConfigServiceDefaults),
82 http_auth_handler_factory_(HttpAuthHandlerFactory::CreateDefault( 82 http_auth_handler_factory_(
83 &host_resolver_)), 83 HttpAuthHandlerFactory::CreateDefault(&host_resolver_)),
84 session_(CreateNetworkSession()), 84 session_(CreateNetworkSession()),
85 direct_transport_socket_params_(new TransportSocketParams( 85 direct_transport_socket_params_(
86 HostPortPair("host", 443), MEDIUM, false, false, 86 new TransportSocketParams(HostPortPair("host", 443),
87 OnHostResolutionCallback())), 87 MEDIUM,
88 false,
89 false,
90 OnHostResolutionCallback())),
88 transport_histograms_("MockTCP"), 91 transport_histograms_("MockTCP"),
89 transport_socket_pool_( 92 transport_socket_pool_(kMaxSockets,
90 kMaxSockets, 93 kMaxSocketsPerGroup,
91 kMaxSocketsPerGroup, 94 &transport_histograms_,
92 &transport_histograms_, 95 &socket_factory_),
93 &socket_factory_), 96 proxy_transport_socket_params_(
94 proxy_transport_socket_params_(new TransportSocketParams( 97 new TransportSocketParams(HostPortPair("proxy", 443),
95 HostPortPair("proxy", 443), MEDIUM, false, false, 98 MEDIUM,
96 OnHostResolutionCallback())), 99 false,
97 socks_socket_params_(new SOCKSSocketParams( 100 false,
98 proxy_transport_socket_params_, true, 101 OnHostResolutionCallback())),
99 HostPortPair("sockshost", 443), MEDIUM)), 102 socks_socket_params_(
103 new SOCKSSocketParams(proxy_transport_socket_params_,
104 true,
105 HostPortPair("sockshost", 443),
106 MEDIUM)),
100 socks_histograms_("MockSOCKS"), 107 socks_histograms_("MockSOCKS"),
101 socks_socket_pool_( 108 socks_socket_pool_(kMaxSockets,
102 kMaxSockets, 109 kMaxSocketsPerGroup,
103 kMaxSocketsPerGroup, 110 &socks_histograms_,
104 &socks_histograms_, 111 &transport_socket_pool_),
105 &transport_socket_pool_), 112 http_proxy_socket_params_(
106 http_proxy_socket_params_(new HttpProxySocketParams( 113 new HttpProxySocketParams(proxy_transport_socket_params_,
107 proxy_transport_socket_params_, NULL, GURL("http://host"), "", 114 NULL,
108 HostPortPair("host", 80), 115 GURL("http://host"),
109 session_->http_auth_cache(), 116 std::string(),
110 session_->http_auth_handler_factory(), 117 HostPortPair("host", 80),
111 session_->spdy_session_pool(), 118 session_->http_auth_cache(),
112 true)), 119 session_->http_auth_handler_factory(),
120 session_->spdy_session_pool(),
121 true)),
113 http_proxy_histograms_("MockHttpProxy"), 122 http_proxy_histograms_("MockHttpProxy"),
114 http_proxy_socket_pool_( 123 http_proxy_socket_pool_(kMaxSockets,
115 kMaxSockets, 124 kMaxSocketsPerGroup,
116 kMaxSocketsPerGroup, 125 &http_proxy_histograms_,
117 &http_proxy_histograms_, 126 &host_resolver_,
118 &host_resolver_, 127 &transport_socket_pool_,
119 &transport_socket_pool_, 128 NULL,
120 NULL, 129 NULL) {
121 NULL) {
122 scoped_refptr<SSLConfigService> ssl_config_service( 130 scoped_refptr<SSLConfigService> ssl_config_service(
123 new SSLConfigServiceDefaults); 131 new SSLConfigServiceDefaults);
124 ssl_config_service->GetSSLConfig(&ssl_config_); 132 ssl_config_service->GetSSLConfig(&ssl_config_);
125 } 133 }
126 134
127 void CreatePool(bool transport_pool, bool http_proxy_pool, bool socks_pool) { 135 void CreatePool(bool transport_pool, bool http_proxy_pool, bool socks_pool) {
128 ssl_histograms_.reset(new ClientSocketPoolHistograms("SSLUnitTest")); 136 ssl_histograms_.reset(new ClientSocketPoolHistograms("SSLUnitTest"));
129 pool_.reset(new SSLClientSocketPool( 137 pool_.reset(new SSLClientSocketPool(
130 kMaxSockets, 138 kMaxSockets,
131 kMaxSocketsPerGroup, 139 kMaxSocketsPerGroup,
132 ssl_histograms_.get(), 140 ssl_histograms_.get(),
133 NULL /* host_resolver */, 141 NULL /* host_resolver */,
134 NULL /* cert_verifier */, 142 NULL /* cert_verifier */,
135 NULL /* server_bound_cert_service */, 143 NULL /* server_bound_cert_service */,
136 NULL /* transport_security_state */, 144 NULL /* transport_security_state */,
137 "" /* ssl_session_cache_shard */, 145 std::string() /* ssl_session_cache_shard */,
138 &socket_factory_, 146 &socket_factory_,
139 transport_pool ? &transport_socket_pool_ : NULL, 147 transport_pool ? &transport_socket_pool_ : NULL,
140 socks_pool ? &socks_socket_pool_ : NULL, 148 socks_pool ? &socks_socket_pool_ : NULL,
141 http_proxy_pool ? &http_proxy_socket_pool_ : NULL, 149 http_proxy_pool ? &http_proxy_socket_pool_ : NULL,
142 NULL, 150 NULL,
143 NULL)); 151 NULL));
144 } 152 }
145 153
146 scoped_refptr<SSLSocketParams> SSLParams(ProxyServer::Scheme proxy, 154 scoped_refptr<SSLSocketParams> SSLParams(ProxyServer::Scheme proxy,
147 bool want_spdy_over_npn) { 155 bool want_spdy_over_npn) {
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 HostPortProxyPair pair; 723 HostPortProxyPair pair;
716 AddressList addresses; 724 AddressList addresses;
717 } test_hosts[] = { 725 } test_hosts[] = {
718 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" }, 726 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" },
719 { "code.google.com", "192.168.0.2,192.168.0.3,192.168.0.5" }, 727 { "code.google.com", "192.168.0.2,192.168.0.3,192.168.0.5" },
720 { "js.webkit.org", "192.168.0.4,192.168.0.1,192.0.2.33" }, 728 { "js.webkit.org", "192.168.0.4,192.168.0.1,192.0.2.33" },
721 }; 729 };
722 730
723 host_resolver_.set_synchronous_mode(true); 731 host_resolver_.set_synchronous_mode(true);
724 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) { 732 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
725 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name, 733 host_resolver_.rules()->AddIPLiteralRule(
726 test_hosts[i].iplist, ""); 734 test_hosts[i].name, test_hosts[i].iplist, std::string());
727 735
728 // This test requires that the HostResolver cache be populated. Normal 736 // This test requires that the HostResolver cache be populated. Normal
729 // code would have done this already, but we do it manually. 737 // code would have done this already, but we do it manually.
730 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort)); 738 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
731 host_resolver_.Resolve(info, &test_hosts[i].addresses, CompletionCallback(), 739 host_resolver_.Resolve(info, &test_hosts[i].addresses, CompletionCallback(),
732 NULL, BoundNetLog()); 740 NULL, BoundNetLog());
733 741
734 // Setup a HostPortProxyPair 742 // Setup a HostPortProxyPair
735 test_hosts[i].pair = HostPortProxyPair( 743 test_hosts[i].pair = HostPortProxyPair(
736 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct()); 744 HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 HostPortProxyPair pair; 806 HostPortProxyPair pair;
799 AddressList addresses; 807 AddressList addresses;
800 } test_hosts[] = { 808 } test_hosts[] = {
801 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" }, 809 { "www.webkit.org", "192.0.2.33,192.168.0.1,192.168.0.5" },
802 { "js.webkit.com", "192.168.0.4,192.168.0.1,192.0.2.33" }, 810 { "js.webkit.com", "192.168.0.4,192.168.0.1,192.0.2.33" },
803 }; 811 };
804 812
805 TestCompletionCallback callback; 813 TestCompletionCallback callback;
806 int rv; 814 int rv;
807 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) { 815 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
808 host_resolver_.rules()->AddIPLiteralRule(test_hosts[i].name, 816 host_resolver_.rules()->AddIPLiteralRule(
809 test_hosts[i].iplist, ""); 817 test_hosts[i].name, test_hosts[i].iplist, std::string());
810 818
811 // This test requires that the HostResolver cache be populated. Normal 819 // This test requires that the HostResolver cache be populated. Normal
812 // code would have done this already, but we do it manually. 820 // code would have done this already, but we do it manually.
813 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort)); 821 HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
814 rv = host_resolver_.Resolve(info, &test_hosts[i].addresses, 822 rv = host_resolver_.Resolve(info, &test_hosts[i].addresses,
815 callback.callback(), NULL, BoundNetLog()); 823 callback.callback(), NULL, BoundNetLog());
816 EXPECT_EQ(OK, callback.GetResult(rv)); 824 EXPECT_EQ(OK, callback.GetResult(rv));
817 825
818 // Setup a HostPortProxyPair 826 // Setup a HostPortProxyPair
819 test_hosts[i].pair = HostPortProxyPair( 827 test_hosts[i].pair = HostPortProxyPair(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 ssl.channel_id_sent = true; 892 ssl.channel_id_sent = true;
885 ssl.SetNextProto(kProtoSPDY2); 893 ssl.SetNextProto(kProtoSPDY2);
886 TestIPPoolingDisabled(&ssl); 894 TestIPPoolingDisabled(&ssl);
887 } 895 }
888 896
889 // It would be nice to also test the timeouts in SSLClientSocketPool. 897 // It would be nice to also test the timeouts in SSLClientSocketPool.
890 898
891 } // namespace 899 } // namespace
892 900
893 } // namespace net 901 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/deterministic_socket_data_unittest.cc ('k') | net/socket/transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698