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

Side by Side Diff: net/http/http_server_properties_impl_unittest.cc

Issue 745373002: Optimized HostPortPair::ToString and CookieMonster::GetAllCookiesForURLWithOptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed GetFlattenedSpdyServer and optimized HostPortPair::ToString(). Created 6 years 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
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_server_properties_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 16 matching lines...) Expand all
27 27
28 class HttpServerPropertiesImplTest : public testing::Test { 28 class HttpServerPropertiesImplTest : public testing::Test {
29 protected: 29 protected:
30 HttpServerPropertiesImpl impl_; 30 HttpServerPropertiesImpl impl_;
31 }; 31 };
32 32
33 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest; 33 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
34 34
35 TEST_F(SpdyServerPropertiesTest, Initialize) { 35 TEST_F(SpdyServerPropertiesTest, Initialize) {
36 HostPortPair spdy_server_google("www.google.com", 443); 36 HostPortPair spdy_server_google("www.google.com", 443);
37 std::string spdy_server_g = 37 std::string spdy_server_g = spdy_server_google.ToString();
38 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_google);
39 38
40 HostPortPair spdy_server_docs("docs.google.com", 443); 39 HostPortPair spdy_server_docs("docs.google.com", 443);
41 std::string spdy_server_d = 40 std::string spdy_server_d = spdy_server_docs.ToString();
42 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_docs);
43 41
44 // Check by initializing NULL spdy servers. 42 // Check by initializing NULL spdy servers.
45 impl_.InitializeSpdyServers(NULL, true); 43 impl_.InitializeSpdyServers(NULL, true);
46 EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); 44 EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google));
47 45
48 // Check by initializing empty spdy servers. 46 // Check by initializing empty spdy servers.
49 std::vector<std::string> spdy_servers; 47 std::vector<std::string> spdy_servers;
50 impl_.InitializeSpdyServers(&spdy_servers, true); 48 impl_.InitializeSpdyServers(&spdy_servers, true);
51 EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google)); 49 EXPECT_FALSE(impl_.SupportsSpdy(spdy_server_google));
52 50
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 146
149 // Check empty server is not added. 147 // Check empty server is not added.
150 HostPortPair spdy_server_empty(std::string(), 443); 148 HostPortPair spdy_server_empty(std::string(), 443);
151 impl_.SetSupportsSpdy(spdy_server_empty, true); 149 impl_.SetSupportsSpdy(spdy_server_empty, true);
152 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 150 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
153 EXPECT_EQ(0U, spdy_server_list.GetSize()); 151 EXPECT_EQ(0U, spdy_server_list.GetSize());
154 152
155 std::string string_value_g; 153 std::string string_value_g;
156 std::string string_value_m; 154 std::string string_value_m;
157 HostPortPair spdy_server_google("www.google.com", 443); 155 HostPortPair spdy_server_google("www.google.com", 443);
158 std::string spdy_server_g = 156 std::string spdy_server_g = spdy_server_google.ToString();
159 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_google);
160 HostPortPair spdy_server_mail("mail.google.com", 443); 157 HostPortPair spdy_server_mail("mail.google.com", 443);
161 std::string spdy_server_m = 158 std::string spdy_server_m = spdy_server_mail.ToString();
162 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_mail);
163 159
164 // Add www.google.com:443 as not supporting SPDY. 160 // Add www.google.com:443 as not supporting SPDY.
165 impl_.SetSupportsSpdy(spdy_server_google, false); 161 impl_.SetSupportsSpdy(spdy_server_google, false);
166 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 162 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
167 EXPECT_EQ(0U, spdy_server_list.GetSize()); 163 EXPECT_EQ(0U, spdy_server_list.GetSize());
168 164
169 // Add www.google.com:443 as supporting SPDY. 165 // Add www.google.com:443 as supporting SPDY.
170 impl_.SetSupportsSpdy(spdy_server_google, true); 166 impl_.SetSupportsSpdy(spdy_server_google, true);
171 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 167 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
172 ASSERT_EQ(1U, spdy_server_list.GetSize()); 168 ASSERT_EQ(1U, spdy_server_list.GetSize());
(...skipping 24 matching lines...) Expand all
197 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); 193 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m));
198 ASSERT_EQ(spdy_server_m, string_value_m); 194 ASSERT_EQ(spdy_server_m, string_value_m);
199 } 195 }
200 196
201 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { 197 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
202 base::ListValue spdy_server_list; 198 base::ListValue spdy_server_list;
203 199
204 std::string string_value_g; 200 std::string string_value_g;
205 std::string string_value_m; 201 std::string string_value_m;
206 HostPortPair spdy_server_google("www.google.com", 443); 202 HostPortPair spdy_server_google("www.google.com", 443);
207 std::string spdy_server_g = 203 std::string spdy_server_g = spdy_server_google.ToString();
208 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_google);
209 HostPortPair spdy_server_mail("mail.google.com", 443); 204 HostPortPair spdy_server_mail("mail.google.com", 443);
210 std::string spdy_server_m = 205 std::string spdy_server_m = spdy_server_mail.ToString();
211 HttpServerPropertiesImpl::GetFlattenedSpdyServer(spdy_server_mail);
212 206
213 // Add www.google.com:443 as supporting SPDY. 207 // Add www.google.com:443 as supporting SPDY.
214 impl_.SetSupportsSpdy(spdy_server_google, true); 208 impl_.SetSupportsSpdy(spdy_server_google, true);
215 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 209 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
216 ASSERT_EQ(1U, spdy_server_list.GetSize()); 210 ASSERT_EQ(1U, spdy_server_list.GetSize());
217 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); 211 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
218 ASSERT_EQ(spdy_server_g, string_value_g); 212 ASSERT_EQ(spdy_server_g, string_value_g);
219 213
220 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and 214 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and
221 // www.google.com:443 are in the list. 215 // www.google.com:443 are in the list.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 EXPECT_EQ("foo", supports_quic1.address); 721 EXPECT_EQ("foo", supports_quic1.address);
728 722
729 impl_.Clear(); 723 impl_.Clear();
730 SupportsQuic supports_quic2 = impl_.GetSupportsQuic(test_host_port_pair); 724 SupportsQuic supports_quic2 = impl_.GetSupportsQuic(test_host_port_pair);
731 EXPECT_FALSE(supports_quic2.used_quic); 725 EXPECT_FALSE(supports_quic2.used_quic);
732 EXPECT_EQ("", supports_quic2.address); 726 EXPECT_EQ("", supports_quic2.address);
733 } 727 }
734 } // namespace 728 } // namespace
735 729
736 } // namespace net 730 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698