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

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

Issue 1904483004: Change SupportsSpdy dict, SpdySettingsMap, ServerNetworkStatsMap, AlternativeServiceMap and disk da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format net Created 4 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
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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/base/ip_address.h" 15 #include "net/base/ip_address.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "url/gurl.h"
17 18
18 namespace base { 19 namespace base {
19 class ListValue; 20 class ListValue;
20 } 21 }
21 22
22 namespace net { 23 namespace net {
23 24
24 class HttpServerPropertiesImplPeer { 25 class HttpServerPropertiesImplPeer {
25 public: 26 public:
26 static void AddBrokenAlternativeServiceWithExpirationTime( 27 static void AddBrokenAlternativeServiceWithExpirationTime(
(...skipping 15 matching lines...) Expand all
42 *os << alternative_service.ToString(); 43 *os << alternative_service.ToString();
43 } 44 }
44 45
45 namespace { 46 namespace {
46 47
47 const int kMaxSupportsSpdyServerHosts = 500; 48 const int kMaxSupportsSpdyServerHosts = 500;
48 const SpdySettingsIds kSpdySettingsId = SETTINGS_UPLOAD_BANDWIDTH; 49 const SpdySettingsIds kSpdySettingsId = SETTINGS_UPLOAD_BANDWIDTH;
49 const SpdySettingsFlags kSpdySettingsFlags = SETTINGS_FLAG_PERSISTED; 50 const SpdySettingsFlags kSpdySettingsFlags = SETTINGS_FLAG_PERSISTED;
50 51
51 struct SpdySettingsDataToVerify { 52 struct SpdySettingsDataToVerify {
52 HostPortPair spdy_server; 53 url::SchemeHostPort spdy_server;
53 uint32_t value; 54 uint32_t value;
54 }; 55 };
55 56
56 class HttpServerPropertiesImplTest : public testing::Test { 57 class HttpServerPropertiesImplTest : public testing::Test {
57 protected: 58 protected:
58 bool HasAlternativeService(const HostPortPair& origin) { 59 bool HasAlternativeService(const url::SchemeHostPort& origin) {
59 const AlternativeServiceVector alternative_service_vector = 60 const AlternativeServiceVector alternative_service_vector =
60 impl_.GetAlternativeServices(origin); 61 impl_.GetAlternativeServices(origin);
61 return !alternative_service_vector.empty(); 62 return !alternative_service_vector.empty();
62 } 63 }
63 64
64 bool SetAlternativeService(const HostPortPair& origin, 65 bool SetAlternativeService(const url::SchemeHostPort& origin,
65 const AlternativeService& alternative_service) { 66 const AlternativeService& alternative_service) {
66 const base::Time expiration = 67 const base::Time expiration =
67 base::Time::Now() + base::TimeDelta::FromDays(1); 68 base::Time::Now() + base::TimeDelta::FromDays(1);
68 return impl_.SetAlternativeService(origin, alternative_service, expiration); 69 return impl_.SetAlternativeService(origin, alternative_service, expiration);
69 } 70 }
70 71
71 void InitializeSpdySettingsUploadBandwidth(SpdySettingsMap* spdy_settings_map, 72 void InitializeSpdySettingsUploadBandwidth(
72 const HostPortPair& spdy_server, 73 SpdySettingsMap* spdy_settings_map,
73 uint32_t value) { 74 const url::SchemeHostPort& spdy_server,
75 uint32_t value) {
74 SettingsMap settings_map; 76 SettingsMap settings_map;
75 settings_map[kSpdySettingsId] = 77 settings_map[kSpdySettingsId] =
76 SettingsFlagsAndValue(kSpdySettingsFlags, value); 78 SettingsFlagsAndValue(kSpdySettingsFlags, value);
77 spdy_settings_map->Put(spdy_server, settings_map); 79 spdy_settings_map->Put(spdy_server, settings_map);
78 } 80 }
79 81
80 void VerifySpdySettingsUploadBandwidth( 82 void VerifySpdySettingsUploadBandwidth(
81 const SpdySettingsDataToVerify* data_to_verify) { 83 const SpdySettingsDataToVerify* data_to_verify) {
82 const SpdySettingsMap& spdy_settings_map = impl_.spdy_settings_map(); 84 const SpdySettingsMap& spdy_settings_map = impl_.spdy_settings_map();
83 int count = 0; 85 int count = 0;
(...skipping 11 matching lines...) Expand all
95 EXPECT_EQ(kSpdySettingsFlags, flags_and_value_memory.first); 97 EXPECT_EQ(kSpdySettingsFlags, flags_and_value_memory.first);
96 EXPECT_EQ(data.value, flags_and_value_memory.second); 98 EXPECT_EQ(data.value, flags_and_value_memory.second);
97 } 99 }
98 } 100 }
99 101
100 HttpServerPropertiesImpl impl_; 102 HttpServerPropertiesImpl impl_;
101 }; 103 };
102 104
103 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest; 105 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
104 106
107 TEST_F(SpdyServerPropertiesTest, InitializeWithSchemeHostPort) {
108 // Check spdy servers are correctly set with SchemeHostPort key.
109 url::SchemeHostPort https_www_server("https", "www.google.com", 443);
110 url::SchemeHostPort http_photo_server("http", "photos.google.com", 80);
111 // Servers with port equal to default port in scheme will drop port components
112 // when calling Serialize().
113 std::string spdy_server_g = https_www_server.Serialize();
114 std::string spdy_server_p = http_photo_server.Serialize();
115
116 url::SchemeHostPort http_google_server("http", "www.google.com", 443);
117 url::SchemeHostPort https_photos_server("https", "photos.google.com", 443);
118 url::SchemeHostPort valid_google_server((GURL("https://www.google.com")));
119
120 // Initializing https://www.google.com:443 and https://photos.google.com:443
121 // as spdy servers.
122 std::vector<std::string> spdy_servers1;
123 spdy_servers1.push_back(spdy_server_g); // Will be 0th index.
124 spdy_servers1.push_back(spdy_server_p); // Will be 1st index.
125 impl_.InitializeSpdyServers(&spdy_servers1, true);
126 EXPECT_TRUE(impl_.SupportsRequestPriority(http_photo_server));
127 EXPECT_TRUE(impl_.SupportsRequestPriority(https_www_server));
128 EXPECT_FALSE(impl_.SupportsRequestPriority(http_google_server));
129 EXPECT_FALSE(impl_.SupportsRequestPriority(https_photos_server));
130 EXPECT_TRUE(impl_.SupportsRequestPriority(valid_google_server));
131 }
132
105 TEST_F(SpdyServerPropertiesTest, Initialize) { 133 TEST_F(SpdyServerPropertiesTest, Initialize) {
106 HostPortPair spdy_server_google("www.google.com", 443); 134 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
107 std::string spdy_server_g = spdy_server_google.ToString(); 135 std::string spdy_server_g = spdy_server_google.Serialize();
108 136
109 HostPortPair spdy_server_photos("photos.google.com", 443); 137 url::SchemeHostPort spdy_server_photos("https", "photos.google.com", 443);
110 std::string spdy_server_p = spdy_server_photos.ToString(); 138 std::string spdy_server_p = spdy_server_photos.Serialize();
111 139
112 HostPortPair spdy_server_docs("docs.google.com", 443); 140 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
113 std::string spdy_server_d = spdy_server_docs.ToString(); 141 std::string spdy_server_d = spdy_server_docs.Serialize();
114 142
115 HostPortPair spdy_server_mail("mail.google.com", 443); 143 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
116 std::string spdy_server_m = spdy_server_mail.ToString(); 144 std::string spdy_server_m = spdy_server_mail.Serialize();
117 145
118 // Check by initializing NULL spdy servers. 146 // Check by initializing NULL spdy servers.
119 impl_.InitializeSpdyServers(NULL, true); 147 impl_.InitializeSpdyServers(NULL, true);
120 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 148 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
121 149
122 // Check by initializing empty spdy servers. 150 // Check by initializing empty spdy servers.
123 std::vector<std::string> spdy_servers; 151 std::vector<std::string> spdy_servers;
124 impl_.InitializeSpdyServers(&spdy_servers, true); 152 impl_.InitializeSpdyServers(&spdy_servers, true);
125 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 153 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
126 154
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 222
195 // Verify photos and mail servers don't support SPDY and other servers support 223 // Verify photos and mail servers don't support SPDY and other servers support
196 // SPDY. 224 // SPDY.
197 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 225 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
198 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 226 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
199 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos)); 227 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos));
200 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 228 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
201 } 229 }
202 230
203 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) { 231 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
204 HostPortPair spdy_server_empty(std::string(), 443); 232 url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
205 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty)); 233 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty));
206 234
207 // Add www.google.com:443 as supporting SPDY. 235 // Add www.google.com:443 as supporting SPDY.
208 HostPortPair spdy_server_google("www.google.com", 443); 236 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
209 impl_.SetSupportsSpdy(spdy_server_google, true); 237 impl_.SetSupportsSpdy(spdy_server_google, true);
210 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 238 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
211 239
212 // Add mail.google.com:443 as not supporting SPDY. 240 // Add mail.google.com:443 as not supporting SPDY.
213 HostPortPair spdy_server_mail("mail.google.com", 443); 241 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
214 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 242 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
215 243
216 // Add docs.google.com:443 as supporting SPDY. 244 // Add docs.google.com:443 as supporting SPDY.
217 HostPortPair spdy_server_docs("docs.google.com", 443); 245 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
218 impl_.SetSupportsSpdy(spdy_server_docs, true); 246 impl_.SetSupportsSpdy(spdy_server_docs, true);
219 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 247 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
220 248
221 // Add www.youtube.com:443 as supporting QUIC. 249 // Add www.youtube.com:443 as supporting QUIC.
222 HostPortPair quic_server_youtube("www.youtube.com", 443); 250 url::SchemeHostPort youtube_server("https", "www.youtube.com", 443);
223 const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443); 251 const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443);
224 SetAlternativeService(quic_server_youtube, alternative_service1); 252 SetAlternativeService(youtube_server, alternative_service1);
225 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); 253 EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
226 254
227 // Add www.example.com:443 with two alternative services, one supporting QUIC. 255 // Add www.example.com:443 with two alternative services, one supporting QUIC.
228 HostPortPair quic_server_example("www.example.com", 443); 256 url::SchemeHostPort example_server("https", "www.example.com", 443);
229 const AlternativeService alternative_service2(NPN_HTTP_2, "", 443); 257 const AlternativeService alternative_service2(NPN_HTTP_2, "", 443);
230 SetAlternativeService(quic_server_example, alternative_service2); 258 SetAlternativeService(example_server, alternative_service2);
231 SetAlternativeService(quic_server_example, alternative_service1); 259 SetAlternativeService(example_server, alternative_service1);
232 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example)); 260 EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
233 261
234 // Verify all the entries are the same after additions. 262 // Verify all the entries are the same after additions.
235 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 263 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
236 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 264 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
237 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 265 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
238 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); 266 EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
239 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example)); 267 EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
240 } 268 }
241 269
242 TEST_F(SpdyServerPropertiesTest, Clear) { 270 TEST_F(SpdyServerPropertiesTest, Clear) {
243 // Add www.google.com:443 and mail.google.com:443 as supporting SPDY. 271 // Add www.google.com:443 and mail.google.com:443 as supporting SPDY.
244 HostPortPair spdy_server_google("www.google.com", 443); 272 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
245 impl_.SetSupportsSpdy(spdy_server_google, true); 273 impl_.SetSupportsSpdy(spdy_server_google, true);
246 HostPortPair spdy_server_mail("mail.google.com", 443); 274 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
247 impl_.SetSupportsSpdy(spdy_server_mail, true); 275 impl_.SetSupportsSpdy(spdy_server_mail, true);
248 276
249 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 277 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
250 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail)); 278 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail));
251 279
252 impl_.Clear(); 280 impl_.Clear();
253 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 281 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
254 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 282 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
255 } 283 }
256 284
257 TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) { 285 TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
258 base::ListValue spdy_server_list; 286 base::ListValue spdy_server_list;
259 287
260 // Check there are no spdy_servers. 288 // Check there are no spdy_servers.
261 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 289 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
262 EXPECT_EQ(0U, spdy_server_list.GetSize()); 290 EXPECT_EQ(0U, spdy_server_list.GetSize());
263 291
264 // Check empty server is not added. 292 // Check empty server is not added.
265 HostPortPair spdy_server_empty(std::string(), 443); 293 url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
266 impl_.SetSupportsSpdy(spdy_server_empty, true); 294 impl_.SetSupportsSpdy(spdy_server_empty, true);
267 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 295 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
268 EXPECT_EQ(0U, spdy_server_list.GetSize()); 296 EXPECT_EQ(0U, spdy_server_list.GetSize());
269 297
270 std::string string_value_g; 298 std::string string_value_g;
271 std::string string_value_m; 299 std::string string_value_m;
272 HostPortPair spdy_server_google("www.google.com", 443); 300 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
273 std::string spdy_server_g = spdy_server_google.ToString(); 301 std::string spdy_server_g = spdy_server_google.Serialize();
274 HostPortPair spdy_server_mail("mail.google.com", 443); 302 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
275 std::string spdy_server_m = spdy_server_mail.ToString(); 303 std::string spdy_server_m = spdy_server_mail.Serialize();
276 304
277 // Add www.google.com:443 as not supporting SPDY. 305 // Add www.google.com:443 as not supporting SPDY.
278 impl_.SetSupportsSpdy(spdy_server_google, false); 306 impl_.SetSupportsSpdy(spdy_server_google, false);
279 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 307 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
280 EXPECT_EQ(0U, spdy_server_list.GetSize()); 308 EXPECT_EQ(0U, spdy_server_list.GetSize());
281 309
282 // Add www.google.com:443 as supporting SPDY. 310 // Add www.google.com:443 as supporting SPDY.
283 impl_.SetSupportsSpdy(spdy_server_google, true); 311 impl_.SetSupportsSpdy(spdy_server_google, true);
284 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 312 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
285 ASSERT_EQ(1U, spdy_server_list.GetSize()); 313 ASSERT_EQ(1U, spdy_server_list.GetSize());
(...skipping 23 matching lines...) Expand all
309 ASSERT_EQ(1U, spdy_server_list.GetSize()); 337 ASSERT_EQ(1U, spdy_server_list.GetSize());
310 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); 338 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m));
311 ASSERT_EQ(spdy_server_m, string_value_m); 339 ASSERT_EQ(spdy_server_m, string_value_m);
312 } 340 }
313 341
314 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { 342 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
315 base::ListValue spdy_server_list; 343 base::ListValue spdy_server_list;
316 344
317 std::string string_value_g; 345 std::string string_value_g;
318 std::string string_value_m; 346 std::string string_value_m;
319 HostPortPair spdy_server_google("www.google.com", 443); 347 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
320 std::string spdy_server_g = spdy_server_google.ToString(); 348 std::string spdy_server_g = spdy_server_google.Serialize();
321 HostPortPair spdy_server_mail("mail.google.com", 443); 349 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
322 std::string spdy_server_m = spdy_server_mail.ToString(); 350 std::string spdy_server_m = spdy_server_mail.Serialize();
323 351
324 // Add www.google.com:443 as supporting SPDY. 352 // Add www.google.com:443 as supporting SPDY.
325 impl_.SetSupportsSpdy(spdy_server_google, true); 353 impl_.SetSupportsSpdy(spdy_server_google, true);
326 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 354 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
327 ASSERT_EQ(1U, spdy_server_list.GetSize()); 355 ASSERT_EQ(1U, spdy_server_list.GetSize());
328 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); 356 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
329 ASSERT_EQ(spdy_server_g, string_value_g); 357 ASSERT_EQ(spdy_server_g, string_value_g);
330 358
331 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and 359 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and
332 // www.google.com:443 are in the list. 360 // www.google.com:443 are in the list.
(...skipping 12 matching lines...) Expand all
345 ASSERT_EQ(2U, spdy_server_list.GetSize()); 373 ASSERT_EQ(2U, spdy_server_list.GetSize());
346 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); 374 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
347 ASSERT_EQ(spdy_server_g, string_value_g); 375 ASSERT_EQ(spdy_server_g, string_value_g);
348 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_m)); 376 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_m));
349 ASSERT_EQ(spdy_server_m, string_value_m); 377 ASSERT_EQ(spdy_server_m, string_value_m);
350 } 378 }
351 379
352 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; 380 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest;
353 381
354 TEST_F(AlternateProtocolServerPropertiesTest, Basic) { 382 TEST_F(AlternateProtocolServerPropertiesTest, Basic) {
355 HostPortPair test_host_port_pair("foo", 80); 383 url::SchemeHostPort test_server("http", "foo", 80);
356 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 384 EXPECT_FALSE(HasAlternativeService(test_server));
357 385
358 AlternativeService alternative_service(NPN_HTTP_2, "foo", 443); 386 AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
359 SetAlternativeService(test_host_port_pair, alternative_service); 387 SetAlternativeService(test_server, alternative_service);
360 const AlternativeServiceVector alternative_service_vector = 388 const AlternativeServiceVector alternative_service_vector =
361 impl_.GetAlternativeServices(test_host_port_pair); 389 impl_.GetAlternativeServices(test_server);
362 ASSERT_EQ(1u, alternative_service_vector.size()); 390 ASSERT_EQ(1u, alternative_service_vector.size());
363 EXPECT_EQ(alternative_service, alternative_service_vector[0]); 391 EXPECT_EQ(alternative_service, alternative_service_vector[0]);
364 392
365 impl_.Clear(); 393 impl_.Clear();
366 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 394 EXPECT_FALSE(HasAlternativeService(test_server));
367 } 395 }
368 396
369 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) { 397 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
370 AlternativeServiceInfoVector alternative_service_info_vector; 398 AlternativeServiceInfoVector alternative_service_info_vector;
371 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 399 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
372 // Same hostname, same port, TCP: should be ignored. 400 // Same hostname, same port, TCP: should be ignored.
373 AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443); 401 AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443);
374 alternative_service_info_vector.push_back( 402 alternative_service_info_vector.push_back(
375 AlternativeServiceInfo(alternative_service1, expiration)); 403 AlternativeServiceInfo(alternative_service1, expiration));
376 // Different hostname: GetAlternativeServices should return this one. 404 // Different hostname: GetAlternativeServices should return this one.
377 AlternativeService alternative_service2(NPN_HTTP_2, "bar", 443); 405 AlternativeService alternative_service2(NPN_HTTP_2, "bar", 443);
378 alternative_service_info_vector.push_back( 406 alternative_service_info_vector.push_back(
379 AlternativeServiceInfo(alternative_service2, expiration)); 407 AlternativeServiceInfo(alternative_service2, expiration));
380 // Different port: GetAlternativeServices should return this one too. 408 // Different port: GetAlternativeServices should return this one too.
381 AlternativeService alternative_service3(NPN_HTTP_2, "foo", 80); 409 AlternativeService alternative_service3(NPN_HTTP_2, "foo", 80);
382 alternative_service_info_vector.push_back( 410 alternative_service_info_vector.push_back(
383 AlternativeServiceInfo(alternative_service3, expiration)); 411 AlternativeServiceInfo(alternative_service3, expiration));
384 // QUIC: GetAlternativeServices should return this one too. 412 // QUIC: GetAlternativeServices should return this one too.
385 AlternativeService alternative_service4(QUIC, "foo", 443); 413 AlternativeService alternative_service4(QUIC, "foo", 443);
386 alternative_service_info_vector.push_back( 414 alternative_service_info_vector.push_back(
387 AlternativeServiceInfo(alternative_service4, expiration)); 415 AlternativeServiceInfo(alternative_service4, expiration));
388 416
389 HostPortPair test_host_port_pair("foo", 443); 417 url::SchemeHostPort test_server("https", "foo", 443);
390 impl_.SetAlternativeServices(test_host_port_pair, 418 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
391 alternative_service_info_vector);
392 419
393 const AlternativeServiceVector alternative_service_vector = 420 const AlternativeServiceVector alternative_service_vector =
394 impl_.GetAlternativeServices(test_host_port_pair); 421 impl_.GetAlternativeServices(test_server);
395 ASSERT_EQ(3u, alternative_service_vector.size()); 422 ASSERT_EQ(3u, alternative_service_vector.size());
396 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 423 EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
397 EXPECT_EQ(alternative_service3, alternative_service_vector[1]); 424 EXPECT_EQ(alternative_service3, alternative_service_vector[1]);
398 EXPECT_EQ(alternative_service4, alternative_service_vector[2]); 425 EXPECT_EQ(alternative_service4, alternative_service_vector[2]);
399 } 426 }
400 427
401 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { 428 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) {
402 // |test_host_port_pair1| has an alternative service, which will not be 429 // |test_server1| has an alternative service, which will not be
403 // affected by InitializeAlternativeServiceServers(), because 430 // affected by InitializeAlternativeServiceServers(), because
404 // |alternative_service_map| does not have an entry for 431 // |alternative_service_map| does not have an entry for
405 // |test_host_port_pair1|. 432 // |test_server1|.
406 HostPortPair test_host_port_pair1("foo1", 80); 433 url::SchemeHostPort test_server1("http", "foo1", 80);
407 const AlternativeService alternative_service1(NPN_HTTP_2, "bar1", 443); 434 const AlternativeService alternative_service1(NPN_HTTP_2, "bar1", 443);
408 const base::Time now = base::Time::Now(); 435 const base::Time now = base::Time::Now();
409 base::Time expiration1 = now + base::TimeDelta::FromDays(1); 436 base::Time expiration1 = now + base::TimeDelta::FromDays(1);
410 // 1st entry in the memory. 437 // 1st entry in the memory.
411 impl_.SetAlternativeService(test_host_port_pair1, alternative_service1, 438 impl_.SetAlternativeService(test_server1, alternative_service1, expiration1);
412 expiration1);
413 439
414 // |test_host_port_pair2| has an alternative service, which will be 440 // |test_server2| has an alternative service, which will be
415 // overwritten by InitializeAlternativeServiceServers(), because 441 // overwritten by InitializeAlternativeServiceServers(), because
416 // |alternative_service_map| has an entry for 442 // |alternative_service_map| has an entry for
417 // |test_host_port_pair2|. 443 // |test_server2|.
418 AlternativeServiceInfoVector alternative_service_info_vector; 444 AlternativeServiceInfoVector alternative_service_info_vector;
419 const AlternativeService alternative_service2(NPN_SPDY_3_1, "bar2", 443); 445 const AlternativeService alternative_service2(NPN_SPDY_3_1, "bar2", 443);
420 base::Time expiration2 = now + base::TimeDelta::FromDays(2); 446 base::Time expiration2 = now + base::TimeDelta::FromDays(2);
421 alternative_service_info_vector.push_back( 447 alternative_service_info_vector.push_back(
422 AlternativeServiceInfo(alternative_service2, expiration2)); 448 AlternativeServiceInfo(alternative_service2, expiration2));
423 HostPortPair test_host_port_pair2("foo2", 80); 449 url::SchemeHostPort test_server2("http", "foo2", 80);
424 // 0th entry in the memory. 450 // 0th entry in the memory.
425 impl_.SetAlternativeServices(test_host_port_pair2, 451 impl_.SetAlternativeServices(test_server2, alternative_service_info_vector);
426 alternative_service_info_vector);
427 452
428 // Prepare |alternative_service_map| to be loaded by 453 // Prepare |alternative_service_map| to be loaded by
429 // InitializeAlternativeServiceServers(). 454 // InitializeAlternativeServiceServers().
430 AlternativeServiceMap alternative_service_map( 455 AlternativeServiceMap alternative_service_map(
431 AlternativeServiceMap::NO_AUTO_EVICT); 456 AlternativeServiceMap::NO_AUTO_EVICT);
432 const AlternativeService alternative_service3(NPN_HTTP_2, "bar3", 123); 457 const AlternativeService alternative_service3(NPN_HTTP_2, "bar3", 123);
433 base::Time expiration3 = now + base::TimeDelta::FromDays(3); 458 base::Time expiration3 = now + base::TimeDelta::FromDays(3);
434 const AlternativeServiceInfo alternative_service_info1(alternative_service3, 459 const AlternativeServiceInfo alternative_service_info1(alternative_service3,
435 expiration3); 460 expiration3);
436 // Simulate updating data for 0th entry with data from Preferences. 461 // Simulate updating data for 0th entry with data from Preferences.
437 alternative_service_map.Put( 462 alternative_service_map.Put(
438 test_host_port_pair2, 463 test_server2,
439 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info1)); 464 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info1));
440 465
441 HostPortPair test_host_port_pair3("foo3", 80); 466 url::SchemeHostPort test_server3("http", "foo3", 80);
442 const AlternativeService alternative_service4(NPN_HTTP_2, "bar4", 1234); 467 const AlternativeService alternative_service4(NPN_HTTP_2, "bar4", 1234);
443 base::Time expiration4 = now + base::TimeDelta::FromDays(4); 468 base::Time expiration4 = now + base::TimeDelta::FromDays(4);
444 const AlternativeServiceInfo alternative_service_info2(alternative_service4, 469 const AlternativeServiceInfo alternative_service_info2(alternative_service4,
445 expiration4); 470 expiration4);
446 // Add an old entry from Preferences, this will be added to end of recency 471 // Add an old entry from Preferences, this will be added to end of recency
447 // list. 472 // list.
448 alternative_service_map.Put( 473 alternative_service_map.Put(
449 test_host_port_pair3, 474 test_server3,
450 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info2)); 475 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info2));
451 476
452 // MRU list will be test_host_port_pair2, test_host_port_pair1, 477 // MRU list will be test_server2, test_server1, test_server3.
453 // test_host_port_pair3.
454 impl_.InitializeAlternativeServiceServers(&alternative_service_map); 478 impl_.InitializeAlternativeServiceServers(&alternative_service_map);
455 479
456 // Verify alternative_service_map. 480 // Verify alternative_service_map.
457 const AlternativeServiceMap& map = impl_.alternative_service_map(); 481 const AlternativeServiceMap& map = impl_.alternative_service_map();
458 ASSERT_EQ(3u, map.size()); 482 ASSERT_EQ(3u, map.size());
459 AlternativeServiceMap::const_iterator map_it = map.begin(); 483 AlternativeServiceMap::const_iterator map_it = map.begin();
460 484
461 EXPECT_TRUE(map_it->first.Equals(test_host_port_pair2)); 485 EXPECT_TRUE(map_it->first.Equals(test_server2));
462 ASSERT_EQ(1u, map_it->second.size()); 486 ASSERT_EQ(1u, map_it->second.size());
463 EXPECT_EQ(alternative_service3, map_it->second[0].alternative_service); 487 EXPECT_EQ(alternative_service3, map_it->second[0].alternative_service);
464 EXPECT_EQ(expiration3, map_it->second[0].expiration); 488 EXPECT_EQ(expiration3, map_it->second[0].expiration);
465 ++map_it; 489 ++map_it;
466 EXPECT_TRUE(map_it->first.Equals(test_host_port_pair1)); 490 EXPECT_TRUE(map_it->first.Equals(test_server1));
467 ASSERT_EQ(1u, map_it->second.size()); 491 ASSERT_EQ(1u, map_it->second.size());
468 EXPECT_EQ(alternative_service1, map_it->second[0].alternative_service); 492 EXPECT_EQ(alternative_service1, map_it->second[0].alternative_service);
469 EXPECT_EQ(expiration1, map_it->second[0].expiration); 493 EXPECT_EQ(expiration1, map_it->second[0].expiration);
470 ++map_it; 494 ++map_it;
471 EXPECT_TRUE(map_it->first.Equals(test_host_port_pair3)); 495 EXPECT_TRUE(map_it->first.Equals(test_server3));
472 ASSERT_EQ(1u, map_it->second.size()); 496 ASSERT_EQ(1u, map_it->second.size());
473 EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service); 497 EXPECT_EQ(alternative_service4, map_it->second[0].alternative_service);
474 EXPECT_EQ(expiration4, map_it->second[0].expiration); 498 EXPECT_EQ(expiration4, map_it->second[0].expiration);
475 } 499 }
476 500
477 // Regression test for https://crbug.com/504032: 501 // Regression test for https://crbug.com/504032:
478 // InitializeAlternativeServiceServers() should not crash if there is an empty 502 // InitializeAlternativeServiceServers() should not crash if there is an empty
479 // hostname is the mapping. 503 // hostname is the mapping.
480 TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) { 504 TEST_F(AlternateProtocolServerPropertiesTest, InitializeWithEmptyHostname) {
481 const HostPortPair host_port_pair("foo", 443); 505 url::SchemeHostPort server("https", "foo", 443);
482 const AlternativeService alternative_service_with_empty_hostname(NPN_HTTP_2, 506 const AlternativeService alternative_service_with_empty_hostname(NPN_HTTP_2,
483 "", 1234); 507 "", 1234);
484 const AlternativeService alternative_service_with_foo_hostname(NPN_HTTP_2, 508 const AlternativeService alternative_service_with_foo_hostname(NPN_HTTP_2,
485 "foo", 1234); 509 "foo", 1234);
486 SetAlternativeService(host_port_pair, 510 SetAlternativeService(server, alternative_service_with_empty_hostname);
487 alternative_service_with_empty_hostname);
488 impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname); 511 impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname);
489 512
490 AlternativeServiceMap alternative_service_map( 513 AlternativeServiceMap alternative_service_map(
491 AlternativeServiceMap::NO_AUTO_EVICT); 514 AlternativeServiceMap::NO_AUTO_EVICT);
492 impl_.InitializeAlternativeServiceServers(&alternative_service_map); 515 impl_.InitializeAlternativeServiceServers(&alternative_service_map);
493 516
494 EXPECT_TRUE( 517 EXPECT_TRUE(
495 impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname)); 518 impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname));
496 const AlternativeServiceVector alternative_service_vector = 519 const AlternativeServiceVector alternative_service_vector =
497 impl_.GetAlternativeServices(host_port_pair); 520 impl_.GetAlternativeServices(server);
498 ASSERT_EQ(1u, alternative_service_vector.size()); 521 ASSERT_EQ(1u, alternative_service_vector.size());
499 EXPECT_EQ(alternative_service_with_foo_hostname, 522 EXPECT_EQ(alternative_service_with_foo_hostname,
500 alternative_service_vector[0]); 523 alternative_service_vector[0]);
501 } 524 }
502 525
503 // Regression test for https://crbug.com/516486: 526 // Regression test for https://crbug.com/516486:
504 // GetAlternativeServices() should remove |alternative_service_map_| elements 527 // GetAlternativeServices() should remove |alternative_service_map_| elements
505 // with empty value. 528 // with empty value.
506 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) { 529 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
507 HostPortPair host_port_pair("foo", 443); 530 url::SchemeHostPort server("https", "foo", 443);
508 const AlternativeService alternative_service(NPN_HTTP_2, "bar", 443); 531 const AlternativeService alternative_service(NPN_HTTP_2, "bar", 443);
509 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); 532 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
510 const AlternativeServiceInfo alternative_service_info(alternative_service, 533 const AlternativeServiceInfo alternative_service_info(alternative_service,
511 expiration); 534 expiration);
512 AlternativeServiceMap alternative_service_map( 535 AlternativeServiceMap alternative_service_map(
513 AlternativeServiceMap::NO_AUTO_EVICT); 536 AlternativeServiceMap::NO_AUTO_EVICT);
514 alternative_service_map.Put( 537 alternative_service_map.Put(
515 host_port_pair, 538 server,
516 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 539 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
517 540
518 // Prepare |alternative_service_map_| with a single key that has a single 541 // Prepare |alternative_service_map_| with a single key that has a single
519 // AlternativeServiceInfo with identical hostname and port. 542 // AlternativeServiceInfo with identical hostname and port.
520 impl_.InitializeAlternativeServiceServers(&alternative_service_map); 543 impl_.InitializeAlternativeServiceServers(&alternative_service_map);
521 544
522 // GetAlternativeServices() should remove such AlternativeServiceInfo from 545 // GetAlternativeServices() should remove such AlternativeServiceInfo from
523 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector 546 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector
524 // corresponding to |host_port_pair|. 547 // corresponding to |server|.
525 AlternativeServiceVector alternative_service_vector = 548 AlternativeServiceVector alternative_service_vector =
526 impl_.GetAlternativeServices(host_port_pair); 549 impl_.GetAlternativeServices(server);
527 ASSERT_TRUE(alternative_service_vector.empty()); 550 ASSERT_TRUE(alternative_service_vector.empty());
528 551
529 // GetAlternativeServices() should remove this key from 552 // GetAlternativeServices() should remove this key from
530 // |alternative_service_map_|, and SetAlternativeServices() should not crash. 553 // |alternative_service_map_|, and SetAlternativeServices() should not crash.
531 impl_.SetAlternativeServices( 554 impl_.SetAlternativeServices(
532 host_port_pair, 555 server,
533 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 556 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
534 557
535 // There should still be no alternative service assigned to |host_port_pair|. 558 // There should still be no alternative service assigned to |server|.
536 alternative_service_vector = impl_.GetAlternativeServices(host_port_pair); 559 alternative_service_vector = impl_.GetAlternativeServices(server);
537 ASSERT_TRUE(alternative_service_vector.empty()); 560 ASSERT_TRUE(alternative_service_vector.empty());
538 } 561 }
539 562
540 // Regression test for https://crbug.com/516486 for the canonical host case. 563 // Regression test for https://crbug.com/516486 for the canonical host case.
541 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) { 564 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
542 HostPortPair host_port_pair("foo.c.youtube.com", 443); 565 url::SchemeHostPort server("https", "foo.c.youtube.com", 443);
543 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 443); 566 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
544 const AlternativeService alternative_service(NPN_HTTP_2, "", 443); 567 const AlternativeService alternative_service(NPN_HTTP_2, "", 443);
545 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); 568 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
546 const AlternativeServiceInfo alternative_service_info(alternative_service, 569 const AlternativeServiceInfo alternative_service_info(alternative_service,
547 expiration); 570 expiration);
548 AlternativeServiceMap alternative_service_map( 571 AlternativeServiceMap alternative_service_map(
549 AlternativeServiceMap::NO_AUTO_EVICT); 572 AlternativeServiceMap::NO_AUTO_EVICT);
550 alternative_service_map.Put( 573 alternative_service_map.Put(
551 canonical_host_port_pair, 574 canonical_server,
552 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 575 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
553 576
554 // Prepare |alternative_service_map_| with a single key that has a single 577 // Prepare |alternative_service_map_| with a single key that has a single
555 // AlternativeServiceInfo with identical hostname and port. 578 // AlternativeServiceInfo with identical hostname and port.
556 impl_.InitializeAlternativeServiceServers(&alternative_service_map); 579 impl_.InitializeAlternativeServiceServers(&alternative_service_map);
557 580
558 // GetAlternativeServices() should remove such AlternativeServiceInfo from 581 // GetAlternativeServices() should remove such AlternativeServiceInfo from
559 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector 582 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector
560 // corresponding to |canonical_host_port_pair|, even when looking up 583 // corresponding to |canonical_server|, even when looking up
561 // alternative services for |host_port_pair|. 584 // alternative services for |server|.
562 AlternativeServiceVector alternative_service_vector = 585 AlternativeServiceVector alternative_service_vector =
563 impl_.GetAlternativeServices(host_port_pair); 586 impl_.GetAlternativeServices(server);
564 ASSERT_TRUE(alternative_service_vector.empty()); 587 ASSERT_TRUE(alternative_service_vector.empty());
565 588
566 // GetAlternativeServices() should remove this key from 589 // GetAlternativeServices() should remove this key from
567 // |alternative_service_map_|, and SetAlternativeServices() should not crash. 590 // |alternative_service_map_|, and SetAlternativeServices() should not crash.
568 impl_.SetAlternativeServices( 591 impl_.SetAlternativeServices(
569 canonical_host_port_pair, 592 canonical_server,
570 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 593 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
571 594
572 // There should still be no alternative service assigned to 595 // There should still be no alternative service assigned to
573 // |canonical_host_port_pair|. 596 // |canonical_server|.
574 alternative_service_vector = 597 alternative_service_vector = impl_.GetAlternativeServices(canonical_server);
575 impl_.GetAlternativeServices(canonical_host_port_pair);
576 ASSERT_TRUE(alternative_service_vector.empty()); 598 ASSERT_TRUE(alternative_service_vector.empty());
577 } 599 }
578 600
579 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) { 601 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) {
580 HostPortPair test_host_port_pair1("foo1", 80); 602 url::SchemeHostPort test_server1("http", "foo1", 80);
581 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443); 603 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443);
582 SetAlternativeService(test_host_port_pair1, alternative_service1); 604 SetAlternativeService(test_server1, alternative_service1);
583 HostPortPair test_host_port_pair2("foo2", 80); 605 url::SchemeHostPort test_server2("http", "foo2", 80);
584 const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234); 606 const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234);
585 SetAlternativeService(test_host_port_pair2, alternative_service2); 607 SetAlternativeService(test_server2, alternative_service2);
586 608
587 const AlternativeServiceMap& map = impl_.alternative_service_map(); 609 const AlternativeServiceMap& map = impl_.alternative_service_map();
588 AlternativeServiceMap::const_iterator it = map.begin(); 610 AlternativeServiceMap::const_iterator it = map.begin();
589 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); 611 EXPECT_TRUE(it->first.Equals(test_server2));
590 ASSERT_EQ(1u, it->second.size()); 612 ASSERT_EQ(1u, it->second.size());
591 EXPECT_EQ(alternative_service2, it->second[0].alternative_service); 613 EXPECT_EQ(alternative_service2, it->second[0].alternative_service);
592 614
593 const AlternativeServiceVector alternative_service_vector = 615 const AlternativeServiceVector alternative_service_vector =
594 impl_.GetAlternativeServices(test_host_port_pair1); 616 impl_.GetAlternativeServices(test_server1);
595 ASSERT_EQ(1u, alternative_service_vector.size()); 617 ASSERT_EQ(1u, alternative_service_vector.size());
596 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 618 EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
597 619
598 // GetAlternativeServices should reorder the AlternateProtocol map. 620 // GetAlternativeServices should reorder the AlternateProtocol map.
599 it = map.begin(); 621 it = map.begin();
600 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); 622 EXPECT_TRUE(it->first.Equals(test_server1));
601 ASSERT_EQ(1u, it->second.size()); 623 ASSERT_EQ(1u, it->second.size());
602 EXPECT_EQ(alternative_service1, it->second[0].alternative_service); 624 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
603 } 625 }
604 626
605 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { 627 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
606 HostPortPair test_host_port_pair("foo", 80); 628 url::SchemeHostPort test_server("http", "foo", 80);
607 const AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443); 629 const AlternativeService alternative_service1(NPN_HTTP_2, "foo", 443);
608 SetAlternativeService(test_host_port_pair, alternative_service1); 630 SetAlternativeService(test_server, alternative_service1);
609 AlternativeServiceVector alternative_service_vector = 631 AlternativeServiceVector alternative_service_vector =
610 impl_.GetAlternativeServices(test_host_port_pair); 632 impl_.GetAlternativeServices(test_server);
611 ASSERT_EQ(1u, alternative_service_vector.size()); 633 ASSERT_EQ(1u, alternative_service_vector.size());
612 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 634 EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
613 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service1)); 635 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service1));
614 636
615 // GetAlternativeServices should return the broken alternative service. 637 // GetAlternativeServices should return the broken alternative service.
616 impl_.MarkAlternativeServiceBroken(alternative_service1); 638 impl_.MarkAlternativeServiceBroken(alternative_service1);
617 alternative_service_vector = 639 alternative_service_vector = impl_.GetAlternativeServices(test_server);
618 impl_.GetAlternativeServices(test_host_port_pair);
619 ASSERT_EQ(1u, alternative_service_vector.size()); 640 ASSERT_EQ(1u, alternative_service_vector.size());
620 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 641 EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
621 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 642 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
622 643
623 // SetAlternativeServices should add a broken alternative service to the map. 644 // SetAlternativeServices should add a broken alternative service to the map.
624 AlternativeServiceInfoVector alternative_service_info_vector; 645 AlternativeServiceInfoVector alternative_service_info_vector;
625 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 646 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
626 alternative_service_info_vector.push_back( 647 alternative_service_info_vector.push_back(
627 AlternativeServiceInfo(alternative_service1, expiration)); 648 AlternativeServiceInfo(alternative_service1, expiration));
628 const AlternativeService alternative_service2(NPN_HTTP_2, "foo", 1234); 649 const AlternativeService alternative_service2(NPN_HTTP_2, "foo", 1234);
629 alternative_service_info_vector.push_back( 650 alternative_service_info_vector.push_back(
630 AlternativeServiceInfo(alternative_service2, expiration)); 651 AlternativeServiceInfo(alternative_service2, expiration));
631 impl_.SetAlternativeServices(test_host_port_pair, 652 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
632 alternative_service_info_vector); 653 alternative_service_vector = impl_.GetAlternativeServices(test_server);
633 alternative_service_vector =
634 impl_.GetAlternativeServices(test_host_port_pair);
635 ASSERT_EQ(2u, alternative_service_vector.size()); 654 ASSERT_EQ(2u, alternative_service_vector.size());
636 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 655 EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
637 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); 656 EXPECT_EQ(alternative_service2, alternative_service_vector[1]);
638 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0])); 657 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0]));
639 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service_vector[1])); 658 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service_vector[1]));
640 659
641 // SetAlternativeService should add a broken alternative service to the map. 660 // SetAlternativeService should add a broken alternative service to the map.
642 SetAlternativeService(test_host_port_pair, alternative_service1); 661 SetAlternativeService(test_server, alternative_service1);
643 alternative_service_vector = 662 alternative_service_vector = impl_.GetAlternativeServices(test_server);
644 impl_.GetAlternativeServices(test_host_port_pair);
645 ASSERT_EQ(1u, alternative_service_vector.size()); 663 ASSERT_EQ(1u, alternative_service_vector.size());
646 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 664 EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
647 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0])); 665 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0]));
648 } 666 }
649 667
650 TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) { 668 TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {
651 AlternativeServiceInfoVector alternative_service_info_vector; 669 AlternativeServiceInfoVector alternative_service_info_vector;
652 base::Time now = base::Time::Now(); 670 base::Time now = base::Time::Now();
653 base::TimeDelta one_day = base::TimeDelta::FromDays(1); 671 base::TimeDelta one_day = base::TimeDelta::FromDays(1);
654 672
655 // First alternative service expired one day ago, should not be returned by 673 // First alternative service expired one day ago, should not be returned by
656 // GetAlternativeServices(). 674 // GetAlternativeServices().
657 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443); 675 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
658 alternative_service_info_vector.push_back( 676 alternative_service_info_vector.push_back(
659 AlternativeServiceInfo(alternative_service1, now - one_day)); 677 AlternativeServiceInfo(alternative_service1, now - one_day));
660 678
661 // Second alterrnative service will expire one day from now, should be 679 // Second alterrnative service will expire one day from now, should be
662 // returned by GetAlternativeSerices(). 680 // returned by GetAlternativeSerices().
663 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234); 681 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
664 alternative_service_info_vector.push_back( 682 alternative_service_info_vector.push_back(
665 AlternativeServiceInfo(alternative_service2, now + one_day)); 683 AlternativeServiceInfo(alternative_service2, now + one_day));
666 684
667 HostPortPair test_host_port_pair("foo", 80); 685 url::SchemeHostPort test_server("http", "foo", 80);
668 impl_.SetAlternativeServices(test_host_port_pair, 686 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
669 alternative_service_info_vector);
670 687
671 AlternativeServiceVector alternative_service_vector = 688 AlternativeServiceVector alternative_service_vector =
672 impl_.GetAlternativeServices(test_host_port_pair); 689 impl_.GetAlternativeServices(test_server);
673 ASSERT_EQ(1u, alternative_service_vector.size()); 690 ASSERT_EQ(1u, alternative_service_vector.size());
674 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 691 EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
675 } 692 }
676 693
677 TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) { 694 TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {
678 AlternativeServiceInfoVector alternative_service_info_vector; 695 AlternativeServiceInfoVector alternative_service_info_vector;
679 base::Time now = base::Time::Now(); 696 base::Time now = base::Time::Now();
680 base::TimeDelta one_day = base::TimeDelta::FromDays(1); 697 base::TimeDelta one_day = base::TimeDelta::FromDays(1);
681 698
682 // First alternative service expired one day ago, should not be returned by 699 // First alternative service expired one day ago, should not be returned by
683 // GetAlternativeServices(). 700 // GetAlternativeServices().
684 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443); 701 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
685 alternative_service_info_vector.push_back( 702 alternative_service_info_vector.push_back(
686 AlternativeServiceInfo(alternative_service1, now - one_day)); 703 AlternativeServiceInfo(alternative_service1, now - one_day));
687 704
688 // Second alterrnative service will expire one day from now, should be 705 // Second alterrnative service will expire one day from now, should be
689 // returned by GetAlternativeSerices(). 706 // returned by GetAlternativeSerices().
690 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234); 707 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
691 alternative_service_info_vector.push_back( 708 alternative_service_info_vector.push_back(
692 AlternativeServiceInfo(alternative_service2, now + one_day)); 709 AlternativeServiceInfo(alternative_service2, now + one_day));
693 710
694 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 711 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
695 impl_.SetAlternativeServices(canonical_host_port_pair, 712 impl_.SetAlternativeServices(canonical_server,
696 alternative_service_info_vector); 713 alternative_service_info_vector);
697 714
698 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 715 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
699 AlternativeServiceVector alternative_service_vector = 716 AlternativeServiceVector alternative_service_vector =
700 impl_.GetAlternativeServices(test_host_port_pair); 717 impl_.GetAlternativeServices(test_server);
701 ASSERT_EQ(1u, alternative_service_vector.size()); 718 ASSERT_EQ(1u, alternative_service_vector.size());
702 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 719 EXPECT_EQ(alternative_service2, alternative_service_vector[0]);
703 } 720 }
704 721
722 TEST_F(AlternateProtocolServerPropertiesTest, AlternativeServiceWithScheme) {
723 AlternativeServiceInfoVector alternative_service_info_vector;
724 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
725 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
726 alternative_service_info_vector.push_back(
727 AlternativeServiceInfo(alternative_service1, expiration));
728 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
729 alternative_service_info_vector.push_back(
730 AlternativeServiceInfo(alternative_service2, expiration));
731 // Set Alt-Svc list for |http_server|.
732 url::SchemeHostPort http_server("http", "foo", 80);
733 impl_.SetAlternativeServices(http_server, alternative_service_info_vector);
734
735 const net::AlternativeServiceMap& map = impl_.alternative_service_map();
736 net::AlternativeServiceMap::const_iterator it = map.begin();
737 EXPECT_TRUE(it->first.Equals(http_server));
738 ASSERT_EQ(2u, it->second.size());
739 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
740 EXPECT_EQ(alternative_service2, it->second[1].alternative_service);
741
742 // Check Alt-Svc list should not be set for |https_server|.
743 url::SchemeHostPort https_server("https", "foo", 80);
744 EXPECT_EQ(0u, impl_.GetAlternativeServices(https_server).size());
745
746 // Set Alt-Svc list for |https_server|.
747 impl_.SetAlternativeServices(https_server, alternative_service_info_vector);
748 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size());
749 EXPECT_EQ(2u, impl_.GetAlternativeServices(http_server).size());
750
751 // Clear Alt-Svc list for |http_server|.
752 impl_.ClearAlternativeServices(http_server);
753 EXPECT_EQ(0u, impl_.GetAlternativeServices(http_server).size());
754 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size());
755 }
756
705 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) { 757 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
706 AlternativeServiceInfoVector alternative_service_info_vector; 758 AlternativeServiceInfoVector alternative_service_info_vector;
707 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443); 759 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo", 443);
708 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 760 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
709 alternative_service_info_vector.push_back( 761 alternative_service_info_vector.push_back(
710 AlternativeServiceInfo(alternative_service1, expiration)); 762 AlternativeServiceInfo(alternative_service1, expiration));
711 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234); 763 const AlternativeService alternative_service2(NPN_HTTP_2, "bar", 1234);
712 alternative_service_info_vector.push_back( 764 alternative_service_info_vector.push_back(
713 AlternativeServiceInfo(alternative_service2, expiration)); 765 AlternativeServiceInfo(alternative_service2, expiration));
714 HostPortPair test_host_port_pair("foo", 80); 766 url::SchemeHostPort test_server("http", "foo", 80);
715 impl_.SetAlternativeServices(test_host_port_pair, 767 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
716 alternative_service_info_vector);
717 768
718 const net::AlternativeServiceMap& map = impl_.alternative_service_map(); 769 const net::AlternativeServiceMap& map = impl_.alternative_service_map();
719 net::AlternativeServiceMap::const_iterator it = map.begin(); 770 net::AlternativeServiceMap::const_iterator it = map.begin();
720 EXPECT_TRUE(it->first.Equals(test_host_port_pair)); 771 EXPECT_TRUE(it->first.Equals(test_server));
721 ASSERT_EQ(2u, it->second.size()); 772 ASSERT_EQ(2u, it->second.size());
722 EXPECT_EQ(alternative_service1, it->second[0].alternative_service); 773 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
723 EXPECT_EQ(alternative_service2, it->second[1].alternative_service); 774 EXPECT_EQ(alternative_service2, it->second[1].alternative_service);
724 775
725 impl_.ClearAlternativeServices(test_host_port_pair); 776 impl_.ClearAlternativeServices(test_server);
726 EXPECT_TRUE(map.empty()); 777 EXPECT_TRUE(map.empty());
727 } 778 }
728 779
729 // A broken alternative service in the mapping carries meaningful information, 780 // A broken alternative service in the mapping carries meaningful information,
730 // therefore it should not be ignored by SetAlternativeService(). In 781 // therefore it should not be ignored by SetAlternativeService(). In
731 // particular, an alternative service mapped to an origin shadows alternative 782 // particular, an alternative service mapped to an origin shadows alternative
732 // services of canonical hosts. 783 // services of canonical hosts.
733 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) { 784 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
734 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 785 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
735 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 786 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
736 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 787 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
737 1234); 788 1234);
738 SetAlternativeService(canonical_host_port_pair, 789 SetAlternativeService(canonical_server, canonical_alternative_service);
739 canonical_alternative_service);
740 AlternativeServiceVector alternative_service_vector = 790 AlternativeServiceVector alternative_service_vector =
741 impl_.GetAlternativeServices(test_host_port_pair); 791 impl_.GetAlternativeServices(test_server);
742 ASSERT_EQ(1u, alternative_service_vector.size()); 792 ASSERT_EQ(1u, alternative_service_vector.size());
743 EXPECT_EQ(canonical_alternative_service, alternative_service_vector[0]); 793 EXPECT_EQ(canonical_alternative_service, alternative_service_vector[0]);
744 794
745 const AlternativeService broken_alternative_service(NPN_HTTP_2, "foo", 443); 795 const AlternativeService broken_alternative_service(NPN_HTTP_2, "foo", 443);
746 impl_.MarkAlternativeServiceBroken(broken_alternative_service); 796 impl_.MarkAlternativeServiceBroken(broken_alternative_service);
747 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); 797 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
748 798
749 SetAlternativeService(test_host_port_pair, broken_alternative_service); 799 SetAlternativeService(test_server, broken_alternative_service);
750 alternative_service_vector = 800 alternative_service_vector = impl_.GetAlternativeServices(test_server);
751 impl_.GetAlternativeServices(test_host_port_pair);
752 ASSERT_EQ(1u, alternative_service_vector.size()); 801 ASSERT_EQ(1u, alternative_service_vector.size());
753 EXPECT_EQ(broken_alternative_service, alternative_service_vector[0]); 802 EXPECT_EQ(broken_alternative_service, alternative_service_vector[0]);
754 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); 803 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
755 } 804 }
756 805
757 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { 806 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
758 HostPortPair test_host_port_pair("foo", 80); 807 url::SchemeHostPort test_server("http", "foo", 80);
759 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443); 808 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
760 SetAlternativeService(test_host_port_pair, alternative_service); 809 SetAlternativeService(test_server, alternative_service);
761 impl_.MarkAlternativeServiceBroken(alternative_service); 810 impl_.MarkAlternativeServiceBroken(alternative_service);
762 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); 811 ASSERT_TRUE(HasAlternativeService(test_server));
763 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 812 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
764 // ClearAlternativeServices should leave a broken alternative service marked 813 // ClearAlternativeServices should leave a broken alternative service marked
765 // as such. 814 // as such.
766 impl_.ClearAlternativeServices(test_host_port_pair); 815 impl_.ClearAlternativeServices(test_server);
767 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 816 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
768 } 817 }
769 818
770 TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) { 819 TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) {
771 HostPortPair host_port_pair("foo", 80); 820 url::SchemeHostPort server("http", "foo", 80);
772 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443); 821 const AlternativeService alternative_service(NPN_HTTP_2, "foo", 443);
773 SetAlternativeService(host_port_pair, alternative_service); 822 SetAlternativeService(server, alternative_service);
774 823
775 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 824 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
776 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 825 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
777 826
778 impl_.MarkAlternativeServiceRecentlyBroken(alternative_service); 827 impl_.MarkAlternativeServiceRecentlyBroken(alternative_service);
779 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 828 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
780 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 829 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
781 830
782 impl_.ConfirmAlternativeService(alternative_service); 831 impl_.ConfirmAlternativeService(alternative_service);
783 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 832 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
784 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 833 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
785 } 834 }
786 835
787 TEST_F(AlternateProtocolServerPropertiesTest, Canonical) { 836 TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
788 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 837 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
789 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 838 EXPECT_FALSE(HasAlternativeService(test_server));
790 839
791 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 840 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
792 EXPECT_FALSE(HasAlternativeService(canonical_host_port_pair)); 841 EXPECT_FALSE(HasAlternativeService(canonical_server));
793 842
794 AlternativeServiceInfoVector alternative_service_info_vector; 843 AlternativeServiceInfoVector alternative_service_info_vector;
795 const AlternativeService canonical_alternative_service1( 844 const AlternativeService canonical_alternative_service1(
796 QUIC, "bar.c.youtube.com", 1234); 845 QUIC, "bar.c.youtube.com", 1234);
797 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 846 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
798 alternative_service_info_vector.push_back( 847 alternative_service_info_vector.push_back(
799 AlternativeServiceInfo(canonical_alternative_service1, expiration)); 848 AlternativeServiceInfo(canonical_alternative_service1, expiration));
800 const AlternativeService canonical_alternative_service2(NPN_HTTP_2, "", 443); 849 const AlternativeService canonical_alternative_service2(NPN_HTTP_2, "", 443);
801 alternative_service_info_vector.push_back( 850 alternative_service_info_vector.push_back(
802 AlternativeServiceInfo(canonical_alternative_service2, expiration)); 851 AlternativeServiceInfo(canonical_alternative_service2, expiration));
803 impl_.SetAlternativeServices(canonical_host_port_pair, 852 impl_.SetAlternativeServices(canonical_server,
804 alternative_service_info_vector); 853 alternative_service_info_vector);
805 854
806 // Since |test_host_port_pair| does not have an alternative service itself, 855 // Since |test_server| does not have an alternative service itself,
807 // GetAlternativeServices should return those of |canonical_host_port_pair|. 856 // GetAlternativeServices should return those of |canonical_server|.
808 AlternativeServiceVector alternative_service_vector = 857 AlternativeServiceVector alternative_service_vector =
809 impl_.GetAlternativeServices(test_host_port_pair); 858 impl_.GetAlternativeServices(test_server);
810 ASSERT_EQ(2u, alternative_service_vector.size()); 859 ASSERT_EQ(2u, alternative_service_vector.size());
811 EXPECT_EQ(canonical_alternative_service1, alternative_service_vector[0]); 860 EXPECT_EQ(canonical_alternative_service1, alternative_service_vector[0]);
812 861
813 // Since |canonical_alternative_service2| has an empty host, 862 // Since |canonical_alternative_service2| has an empty host,
814 // GetAlternativeServices should substitute the hostname of its |origin| 863 // GetAlternativeServices should substitute the hostname of its |origin|
815 // argument. 864 // argument.
816 EXPECT_EQ(test_host_port_pair.host(), alternative_service_vector[1].host); 865 EXPECT_EQ(test_server.host(), alternative_service_vector[1].host);
817 EXPECT_EQ(canonical_alternative_service2.protocol, 866 EXPECT_EQ(canonical_alternative_service2.protocol,
818 alternative_service_vector[1].protocol); 867 alternative_service_vector[1].protocol);
819 EXPECT_EQ(canonical_alternative_service2.port, 868 EXPECT_EQ(canonical_alternative_service2.port,
820 alternative_service_vector[1].port); 869 alternative_service_vector[1].port);
821 870
822 // Verify the canonical suffix. 871 // Verify the canonical suffix.
872 EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(test_server.host()));
823 EXPECT_EQ(".c.youtube.com", 873 EXPECT_EQ(".c.youtube.com",
824 impl_.GetCanonicalSuffix(test_host_port_pair.host())); 874 impl_.GetCanonicalSuffix(canonical_server.host()));
825 EXPECT_EQ(".c.youtube.com",
826 impl_.GetCanonicalSuffix(canonical_host_port_pair.host()));
827 } 875 }
828 876
829 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { 877 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
830 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 878 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
831 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 879 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
832 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 880 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
833 1234); 881 1234);
834 882
835 SetAlternativeService(canonical_host_port_pair, 883 SetAlternativeService(canonical_server, canonical_alternative_service);
836 canonical_alternative_service); 884 impl_.ClearAlternativeServices(canonical_server);
837 impl_.ClearAlternativeServices(canonical_host_port_pair); 885 EXPECT_FALSE(HasAlternativeService(test_server));
838 EXPECT_FALSE(HasAlternativeService(test_host_port_pair));
839 } 886 }
840 887
841 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) { 888 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {
842 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 889 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
843 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 890 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
844 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 891 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
845 1234); 892 1234);
846 893
847 SetAlternativeService(canonical_host_port_pair, 894 SetAlternativeService(canonical_server, canonical_alternative_service);
848 canonical_alternative_service);
849 impl_.MarkAlternativeServiceBroken(canonical_alternative_service); 895 impl_.MarkAlternativeServiceBroken(canonical_alternative_service);
850 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 896 EXPECT_FALSE(HasAlternativeService(test_server));
851 } 897 }
852 898
853 // Adding an alternative service for a new host overrides canonical host. 899 // Adding an alternative service for a new host overrides canonical host.
854 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) { 900 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) {
855 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 901 url::SchemeHostPort foo_server("https", "foo.c.youtube.com", 443);
856 HostPortPair bar_host_port_pair("bar.c.youtube.com", 80); 902 url::SchemeHostPort bar_server("https", "bar.c.youtube.com", 443);
857 AlternativeService bar_alternative_service(QUIC, "bar.c.youtube.com", 1234); 903 AlternativeService bar_alternative_service(QUIC, "bar.c.youtube.com", 1234);
858 SetAlternativeService(bar_host_port_pair, bar_alternative_service); 904 SetAlternativeService(bar_server, bar_alternative_service);
859 AlternativeServiceVector alternative_service_vector = 905 AlternativeServiceVector alternative_service_vector =
860 impl_.GetAlternativeServices(test_host_port_pair); 906 impl_.GetAlternativeServices(foo_server);
861 ASSERT_EQ(1u, alternative_service_vector.size()); 907 ASSERT_EQ(1u, alternative_service_vector.size());
862 EXPECT_EQ(bar_alternative_service, alternative_service_vector[0]); 908 EXPECT_EQ(bar_alternative_service, alternative_service_vector[0]);
863 909
864 HostPortPair qux_host_port_pair("qux.c.youtube.com", 80); 910 url::SchemeHostPort qux_server("https", "qux.c.youtube.com", 443);
865 AlternativeService qux_alternative_service(QUIC, "qux.c.youtube.com", 443); 911 AlternativeService qux_alternative_service(QUIC, "qux.c.youtube.com", 443);
866 SetAlternativeService(qux_host_port_pair, qux_alternative_service); 912 SetAlternativeService(qux_server, qux_alternative_service);
867 alternative_service_vector = 913 alternative_service_vector = impl_.GetAlternativeServices(foo_server);
868 impl_.GetAlternativeServices(test_host_port_pair);
869 ASSERT_EQ(1u, alternative_service_vector.size()); 914 ASSERT_EQ(1u, alternative_service_vector.size());
870 EXPECT_EQ(qux_alternative_service, alternative_service_vector[0]); 915 EXPECT_EQ(qux_alternative_service, alternative_service_vector[0]);
871 } 916 }
872 917
873 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) { 918 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) {
874 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); 919 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
875 HostPortPair canonical_host_port_pair("bar.c.youtube.com", 80); 920 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
876 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com", 921 AlternativeService canonical_alternative_service(QUIC, "bar.c.youtube.com",
877 1234); 922 1234);
878 923
879 SetAlternativeService(canonical_host_port_pair, 924 SetAlternativeService(canonical_server, canonical_alternative_service);
880 canonical_alternative_service);
881 impl_.Clear(); 925 impl_.Clear();
882 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); 926 EXPECT_FALSE(HasAlternativeService(test_server));
883 } 927 }
884 928
885 TEST_F(AlternateProtocolServerPropertiesTest, 929 TEST_F(AlternateProtocolServerPropertiesTest,
886 ExpireBrokenAlternateProtocolMappings) { 930 ExpireBrokenAlternateProtocolMappings) {
887 HostPortPair host_port_pair("foo", 443); 931 url::SchemeHostPort server("https", "foo", 443);
888 AlternativeService alternative_service(QUIC, "foo", 443); 932 AlternativeService alternative_service(QUIC, "foo", 443);
889 SetAlternativeService(host_port_pair, alternative_service); 933 SetAlternativeService(server, alternative_service);
890 EXPECT_TRUE(HasAlternativeService(host_port_pair)); 934 EXPECT_TRUE(HasAlternativeService(server));
891 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 935 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
892 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 936 EXPECT_FALSE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
893 937
894 base::TimeTicks past = 938 base::TimeTicks past =
895 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(42); 939 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(42);
896 HttpServerPropertiesImplPeer::AddBrokenAlternativeServiceWithExpirationTime( 940 HttpServerPropertiesImplPeer::AddBrokenAlternativeServiceWithExpirationTime(
897 impl_, alternative_service, past); 941 impl_, alternative_service, past);
898 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 942 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
899 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 943 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
900 944
901 HttpServerPropertiesImplPeer::ExpireBrokenAlternateProtocolMappings(impl_); 945 HttpServerPropertiesImplPeer::ExpireBrokenAlternateProtocolMappings(impl_);
902 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service)); 946 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service));
903 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service)); 947 EXPECT_TRUE(impl_.WasAlternativeServiceRecentlyBroken(alternative_service));
904 } 948 }
905 949
906 // Regression test for https://crbug.com/505413. 950 // Regression test for https://crbug.com/505413.
907 TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) { 951 TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) {
908 HostPortPair foo_host_port_pair("foo", 443); 952 url::SchemeHostPort foo_server("https", "foo", 443);
909 AlternativeService bar_alternative_service(QUIC, "bar", 443); 953 AlternativeService bar_alternative_service(QUIC, "bar", 443);
910 SetAlternativeService(foo_host_port_pair, bar_alternative_service); 954 SetAlternativeService(foo_server, bar_alternative_service);
911 EXPECT_TRUE(HasAlternativeService(foo_host_port_pair)); 955 EXPECT_TRUE(HasAlternativeService(foo_server));
912 956
913 HostPortPair bar_host_port_pair1("bar", 80); 957 url::SchemeHostPort bar_server1("http", "bar", 80);
914 AlternativeService nohost_alternative_service(QUIC, "", 443); 958 AlternativeService nohost_alternative_service(QUIC, "", 443);
915 SetAlternativeService(bar_host_port_pair1, nohost_alternative_service); 959 SetAlternativeService(bar_server1, nohost_alternative_service);
916 EXPECT_TRUE(HasAlternativeService(bar_host_port_pair1)); 960 EXPECT_TRUE(HasAlternativeService(bar_server1));
917 961
918 HostPortPair bar_host_port_pair2("bar", 443); 962 url::SchemeHostPort bar_server2("https", "bar", 443);
919 AlternativeService baz_alternative_service(QUIC, "baz", 1234); 963 AlternativeService baz_alternative_service(QUIC, "baz", 1234);
920 SetAlternativeService(bar_host_port_pair2, baz_alternative_service); 964 SetAlternativeService(bar_server2, baz_alternative_service);
921 EXPECT_TRUE(HasAlternativeService(bar_host_port_pair2)); 965 EXPECT_TRUE(HasAlternativeService(bar_server2));
922 966
923 // Mark "bar:443" as broken. 967 // Mark "bar:443" as broken.
924 base::TimeTicks past = 968 base::TimeTicks past =
925 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(42); 969 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(42);
926 HttpServerPropertiesImplPeer::AddBrokenAlternativeServiceWithExpirationTime( 970 HttpServerPropertiesImplPeer::AddBrokenAlternativeServiceWithExpirationTime(
927 impl_, bar_alternative_service, past); 971 impl_, bar_alternative_service, past);
928 972
929 // Expire brokenness of "bar:443". 973 // Expire brokenness of "bar:443".
930 HttpServerPropertiesImplPeer::ExpireBrokenAlternateProtocolMappings(impl_); 974 HttpServerPropertiesImplPeer::ExpireBrokenAlternateProtocolMappings(impl_);
931 975
932 // "foo:443" should have no alternative service now. 976 // "foo:443" should have no alternative service now.
933 EXPECT_FALSE(HasAlternativeService(foo_host_port_pair)); 977 EXPECT_FALSE(HasAlternativeService(foo_server));
934 // "bar:80" should have no alternative service now. 978 // "bar:80" should have no alternative service now.
935 EXPECT_FALSE(HasAlternativeService(bar_host_port_pair1)); 979 EXPECT_FALSE(HasAlternativeService(bar_server1));
936 // The alternative service of "bar:443" should be unaffected. 980 // The alternative service of "bar:443" should be unaffected.
937 EXPECT_TRUE(HasAlternativeService(bar_host_port_pair2)); 981 EXPECT_TRUE(HasAlternativeService(bar_server2));
938 982
939 EXPECT_TRUE( 983 EXPECT_TRUE(
940 impl_.WasAlternativeServiceRecentlyBroken(bar_alternative_service)); 984 impl_.WasAlternativeServiceRecentlyBroken(bar_alternative_service));
941 EXPECT_FALSE( 985 EXPECT_FALSE(
942 impl_.WasAlternativeServiceRecentlyBroken(baz_alternative_service)); 986 impl_.WasAlternativeServiceRecentlyBroken(baz_alternative_service));
943 } 987 }
944 988
945 typedef HttpServerPropertiesImplTest SpdySettingsServerPropertiesTest; 989 typedef HttpServerPropertiesImplTest SpdySettingsServerPropertiesTest;
946 990
947 TEST_F(SpdySettingsServerPropertiesTest, Initialize) { 991 TEST_F(SpdySettingsServerPropertiesTest, Initialize) {
948 HostPortPair spdy_server_google("www.google.com", 443); 992 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
949 HostPortPair spdy_server_photos("photos.google.com", 443); 993 url::SchemeHostPort spdy_server_photos("https", "photos.google.com", 443);
950 HostPortPair spdy_server_docs("docs.google.com", 443); 994 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
951 HostPortPair spdy_server_mail("mail.google.com", 443); 995 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
952 996
953 // Check by initializing empty spdy settings. 997 // Check by initializing empty spdy settings.
954 SpdySettingsMap spdy_settings_map(SpdySettingsMap::NO_AUTO_EVICT); 998 SpdySettingsMap spdy_settings_map(SpdySettingsMap::NO_AUTO_EVICT);
955 impl_.InitializeSpdySettingsServers(&spdy_settings_map); 999 impl_.InitializeSpdySettingsServers(&spdy_settings_map);
956 EXPECT_TRUE(impl_.GetSpdySettings(spdy_server_google).empty()); 1000 EXPECT_TRUE(impl_.GetSpdySettings(spdy_server_google).empty());
957 1001
958 // Check by initializing spdy server settings for www.google.com:443 and 1002 // Check by initializing spdy server settings for www.google.com:443 and
959 // photos.google.com:443. 1003 // photos.google.com:443.
960 const SpdySettingsDataToVerify data_to_verify1[] = { 1004 const SpdySettingsDataToVerify data_to_verify1[] = {
961 {spdy_server_google, 10000}, {spdy_server_photos, 20000}, 1005 {spdy_server_google, 10000}, {spdy_server_photos, 20000},
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 data_to_verify3[3].spdy_server, 1047 data_to_verify3[3].spdy_server,
1004 data_to_verify3[3].value); 1048 data_to_verify3[3].value);
1005 InitializeSpdySettingsUploadBandwidth(&spdy_settings_map3, 1049 InitializeSpdySettingsUploadBandwidth(&spdy_settings_map3,
1006 data_to_verify3[1].spdy_server, 1050 data_to_verify3[1].spdy_server,
1007 data_to_verify3[1].value); 1051 data_to_verify3[1].value);
1008 impl_.InitializeSpdySettingsServers(&spdy_settings_map3); 1052 impl_.InitializeSpdySettingsServers(&spdy_settings_map3);
1009 VerifySpdySettingsUploadBandwidth(data_to_verify3); 1053 VerifySpdySettingsUploadBandwidth(data_to_verify3);
1010 } 1054 }
1011 1055
1012 TEST_F(SpdySettingsServerPropertiesTest, SetSpdySetting) { 1056 TEST_F(SpdySettingsServerPropertiesTest, SetSpdySetting) {
1013 HostPortPair spdy_server_empty(std::string(), 443); 1057 url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
1014 const SettingsMap& settings_map0 = impl_.GetSpdySettings(spdy_server_empty); 1058 const SettingsMap& settings_map0 = impl_.GetSpdySettings(spdy_server_empty);
1015 EXPECT_EQ(0U, settings_map0.size()); // Returns kEmptySettingsMap. 1059 EXPECT_EQ(0U, settings_map0.size()); // Returns kEmptySettingsMap.
1016 1060
1017 // Add www.google.com:443 as persisting. 1061 // Add www.google.com:443 as persisting.
1018 HostPortPair spdy_server_google("www.google.com", 443); 1062 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
1019 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH; 1063 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
1020 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST; 1064 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
1021 const uint32_t value1 = 31337; 1065 const uint32_t value1 = 31337;
1022 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1)); 1066 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1));
1023 // Check the values. 1067 // Check the values.
1024 const SettingsMap& settings_map1_ret = 1068 const SettingsMap& settings_map1_ret =
1025 impl_.GetSpdySettings(spdy_server_google); 1069 impl_.GetSpdySettings(spdy_server_google);
1026 ASSERT_EQ(1U, settings_map1_ret.size()); 1070 ASSERT_EQ(1U, settings_map1_ret.size());
1027 SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); 1071 SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
1028 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); 1072 EXPECT_TRUE(it1_ret != settings_map1_ret.end());
1029 SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; 1073 SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second;
1030 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); 1074 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first);
1031 EXPECT_EQ(value1, flags_and_value1_ret.second); 1075 EXPECT_EQ(value1, flags_and_value1_ret.second);
1032 1076
1033 // Add mail.google.com:443 as not persisting. 1077 // Add mail.google.com:443 as not persisting.
1034 HostPortPair spdy_server_mail("mail.google.com", 443); 1078 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
1035 const SpdySettingsIds id2 = SETTINGS_DOWNLOAD_BANDWIDTH; 1079 const SpdySettingsIds id2 = SETTINGS_DOWNLOAD_BANDWIDTH;
1036 const SpdySettingsFlags flags2 = SETTINGS_FLAG_NONE; 1080 const SpdySettingsFlags flags2 = SETTINGS_FLAG_NONE;
1037 const uint32_t value2 = 62667; 1081 const uint32_t value2 = 62667;
1038 EXPECT_FALSE(impl_.SetSpdySetting(spdy_server_mail, id2, flags2, value2)); 1082 EXPECT_FALSE(impl_.SetSpdySetting(spdy_server_mail, id2, flags2, value2));
1039 const SettingsMap& settings_map2_ret = 1083 const SettingsMap& settings_map2_ret =
1040 impl_.GetSpdySettings(spdy_server_mail); 1084 impl_.GetSpdySettings(spdy_server_mail);
1041 EXPECT_EQ(0U, settings_map2_ret.size()); // Returns kEmptySettingsMap. 1085 EXPECT_EQ(0U, settings_map2_ret.size()); // Returns kEmptySettingsMap.
1042 1086
1043 // Add docs.google.com:443 as persisting 1087 // Add docs.google.com:443 as persisting
1044 HostPortPair spdy_server_docs("docs.google.com", 443); 1088 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
1045 const SpdySettingsIds id3 = SETTINGS_ROUND_TRIP_TIME; 1089 const SpdySettingsIds id3 = SETTINGS_ROUND_TRIP_TIME;
1046 const SpdySettingsFlags flags3 = SETTINGS_FLAG_PLEASE_PERSIST; 1090 const SpdySettingsFlags flags3 = SETTINGS_FLAG_PLEASE_PERSIST;
1047 const uint32_t value3 = 93997; 1091 const uint32_t value3 = 93997;
1048 SettingsFlagsAndValue flags_and_value3(flags3, value3); 1092 SettingsFlagsAndValue flags_and_value3(flags3, value3);
1049 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id3, flags3, value3)); 1093 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id3, flags3, value3));
1050 // Check the values. 1094 // Check the values.
1051 const SettingsMap& settings_map3_ret = 1095 const SettingsMap& settings_map3_ret =
1052 impl_.GetSpdySettings(spdy_server_docs); 1096 impl_.GetSpdySettings(spdy_server_docs);
1053 ASSERT_EQ(1U, settings_map3_ret.size()); 1097 ASSERT_EQ(1U, settings_map3_ret.size());
1054 SettingsMap::const_iterator it3_ret = settings_map3_ret.find(id3); 1098 SettingsMap::const_iterator it3_ret = settings_map3_ret.find(id3);
(...skipping 18 matching lines...) Expand all
1073 const SettingsMap& settings_map5_ret = 1117 const SettingsMap& settings_map5_ret =
1074 impl_.GetSpdySettings(spdy_server_google); 1118 impl_.GetSpdySettings(spdy_server_google);
1075 ASSERT_EQ(0U, settings_map5_ret.size()); 1119 ASSERT_EQ(0U, settings_map5_ret.size());
1076 1120
1077 // Clear all settings. 1121 // Clear all settings.
1078 ASSERT_GT(impl_.spdy_settings_map().size(), 0U); 1122 ASSERT_GT(impl_.spdy_settings_map().size(), 0U);
1079 impl_.ClearAllSpdySettings(); 1123 impl_.ClearAllSpdySettings();
1080 ASSERT_EQ(0U, impl_.spdy_settings_map().size()); 1124 ASSERT_EQ(0U, impl_.spdy_settings_map().size());
1081 } 1125 }
1082 1126
1127 TEST_F(SpdySettingsServerPropertiesTest, SpdySettingWithSchemeHostPort) {
1128 // Test SpdySettingMap is correctly maintained with setting and
1129 // clearing method.
1130 // Add https://www.google.com:443 as persisting.
1131 url::SchemeHostPort https_www_server("https", "www.google.com", 443);
1132 url::SchemeHostPort http_www_server("http", "www.google.com", 443);
1133 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
1134 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
1135 const uint32_t value1 = 31337;
1136 EXPECT_TRUE(impl_.SetSpdySetting(https_www_server, id1, flags1, value1));
1137 // Check the values.
1138 const SettingsMap& settings_map1_ret =
1139 impl_.GetSpdySettings(https_www_server);
1140 ASSERT_EQ(1U, settings_map1_ret.size());
1141 SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
1142 EXPECT_TRUE(it1_ret != settings_map1_ret.end());
1143 SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second;
1144 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first);
1145 EXPECT_EQ(value1, flags_and_value1_ret.second);
1146 // Check the values is not set for http server.
1147 const SettingsMap& settings_map1_ret2 =
1148 impl_.GetSpdySettings(http_www_server);
1149 ASSERT_EQ(0U, settings_map1_ret2.size());
1150
1151 // Add http://www.google.com:443 as persisting
1152 const SpdySettingsIds id2 = SETTINGS_ROUND_TRIP_TIME;
1153 const SpdySettingsFlags flags2 = SETTINGS_FLAG_PLEASE_PERSIST;
1154 const uint32_t value2 = 93997;
1155 SettingsFlagsAndValue flags_and_value2(flags2, value2);
1156 EXPECT_TRUE(impl_.SetSpdySetting(http_www_server, id2, flags2, value2));
1157 // Check the values.
1158 const SettingsMap& settings_map2_ret = impl_.GetSpdySettings(http_www_server);
1159 ASSERT_EQ(1U, settings_map2_ret.size());
1160 SettingsMap::const_iterator it2_ret = settings_map2_ret.find(id2);
1161 EXPECT_TRUE(it2_ret != settings_map2_ret.end());
1162 SettingsFlagsAndValue flags_and_value2_ret = it2_ret->second;
1163 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2_ret.first);
1164 EXPECT_EQ(value2, flags_and_value2_ret.second);
1165
1166 // Clear https://www.google.com:443 as persisting.
1167 impl_.ClearSpdySettings(https_www_server);
1168 // Check the values.
1169 const SettingsMap& settings_map3_ret =
1170 impl_.GetSpdySettings(https_www_server);
1171 ASSERT_EQ(0U, settings_map3_ret.size());
1172 // Check the setting is not cleared for http server.
1173 const SettingsMap& settings_map3_ret2 =
1174 impl_.GetSpdySettings(http_www_server);
1175 ASSERT_EQ(1U, settings_map3_ret2.size());
1176
1177 // Clear all settings.
1178 ASSERT_GT(impl_.spdy_settings_map().size(), 0U);
1179 impl_.ClearAllSpdySettings();
1180 ASSERT_EQ(0U, impl_.spdy_settings_map().size());
1181 }
1182
1083 TEST_F(SpdySettingsServerPropertiesTest, Clear) { 1183 TEST_F(SpdySettingsServerPropertiesTest, Clear) {
1084 // Add www.google.com:443 as persisting. 1184 // Add www.google.com:443 as persisting.
1085 HostPortPair spdy_server_google("www.google.com", 443); 1185 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
1086 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH; 1186 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
1087 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST; 1187 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
1088 const uint32_t value1 = 31337; 1188 const uint32_t value1 = 31337;
1089 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1)); 1189 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1));
1090 // Check the values. 1190 // Check the values.
1091 const SettingsMap& settings_map1_ret = 1191 const SettingsMap& settings_map1_ret =
1092 impl_.GetSpdySettings(spdy_server_google); 1192 impl_.GetSpdySettings(spdy_server_google);
1093 ASSERT_EQ(1U, settings_map1_ret.size()); 1193 ASSERT_EQ(1U, settings_map1_ret.size());
1094 SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1); 1194 SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
1095 EXPECT_TRUE(it1_ret != settings_map1_ret.end()); 1195 EXPECT_TRUE(it1_ret != settings_map1_ret.end());
1096 SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second; 1196 SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second;
1097 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); 1197 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first);
1098 EXPECT_EQ(value1, flags_and_value1_ret.second); 1198 EXPECT_EQ(value1, flags_and_value1_ret.second);
1099 1199
1100 // Add docs.google.com:443 as persisting 1200 // Add docs.google.com:443 as persisting
1101 HostPortPair spdy_server_docs("docs.google.com", 443); 1201 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
1102 const SpdySettingsIds id3 = SETTINGS_ROUND_TRIP_TIME; 1202 const SpdySettingsIds id3 = SETTINGS_ROUND_TRIP_TIME;
1103 const SpdySettingsFlags flags3 = SETTINGS_FLAG_PLEASE_PERSIST; 1203 const SpdySettingsFlags flags3 = SETTINGS_FLAG_PLEASE_PERSIST;
1104 const uint32_t value3 = 93997; 1204 const uint32_t value3 = 93997;
1105 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id3, flags3, value3)); 1205 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id3, flags3, value3));
1106 // Check the values. 1206 // Check the values.
1107 const SettingsMap& settings_map3_ret = 1207 const SettingsMap& settings_map3_ret =
1108 impl_.GetSpdySettings(spdy_server_docs); 1208 impl_.GetSpdySettings(spdy_server_docs);
1109 ASSERT_EQ(1U, settings_map3_ret.size()); 1209 ASSERT_EQ(1U, settings_map3_ret.size());
1110 SettingsMap::const_iterator it3_ret = settings_map3_ret.find(id3); 1210 SettingsMap::const_iterator it3_ret = settings_map3_ret.find(id3);
1111 EXPECT_TRUE(it3_ret != settings_map3_ret.end()); 1211 EXPECT_TRUE(it3_ret != settings_map3_ret.end());
1112 SettingsFlagsAndValue flags_and_value3_ret = it3_ret->second; 1212 SettingsFlagsAndValue flags_and_value3_ret = it3_ret->second;
1113 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3_ret.first); 1213 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3_ret.first);
1114 EXPECT_EQ(value3, flags_and_value3_ret.second); 1214 EXPECT_EQ(value3, flags_and_value3_ret.second);
1115 1215
1116 impl_.Clear(); 1216 impl_.Clear();
1117 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_google).size()); 1217 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_google).size());
1118 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_docs).size()); 1218 EXPECT_EQ(0U, impl_.GetSpdySettings(spdy_server_docs).size());
1119 } 1219 }
1120 1220
1121 TEST_F(SpdySettingsServerPropertiesTest, MRUOfGetSpdySettings) { 1221 TEST_F(SpdySettingsServerPropertiesTest, MRUOfGetSpdySettings) {
1122 // Add www.google.com:443 as persisting. 1222 // Add www.google.com:443 as persisting.
1123 HostPortPair spdy_server_google("www.google.com", 443); 1223 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
1124 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH; 1224 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
1125 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST; 1225 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
1126 const uint32_t value1 = 31337; 1226 const uint32_t value1 = 31337;
1127 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1)); 1227 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_google, id1, flags1, value1));
1128 1228
1129 // Add docs.google.com:443 as persisting 1229 // Add docs.google.com:443 as persisting
1130 HostPortPair spdy_server_docs("docs.google.com", 443); 1230 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
1131 const SpdySettingsIds id2 = SETTINGS_ROUND_TRIP_TIME; 1231 const SpdySettingsIds id2 = SETTINGS_ROUND_TRIP_TIME;
1132 const SpdySettingsFlags flags2 = SETTINGS_FLAG_PLEASE_PERSIST; 1232 const SpdySettingsFlags flags2 = SETTINGS_FLAG_PLEASE_PERSIST;
1133 const uint32_t value2 = 93997; 1233 const uint32_t value2 = 93997;
1134 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id2, flags2, value2)); 1234 EXPECT_TRUE(impl_.SetSpdySetting(spdy_server_docs, id2, flags2, value2));
1135 1235
1136 // Verify the first element is docs.google.com:443. 1236 // Verify the first element is docs.google.com:443.
1137 const SpdySettingsMap& map = impl_.spdy_settings_map(); 1237 const SpdySettingsMap& map = impl_.spdy_settings_map();
1138 SpdySettingsMap::const_iterator it = map.begin(); 1238 SpdySettingsMap::const_iterator it = map.begin();
1139 EXPECT_TRUE(it->first.Equals(spdy_server_docs)); 1239 EXPECT_TRUE(it->first.Equals(spdy_server_docs));
1140 const SettingsMap& settings_map2_ret = it->second; 1240 const SettingsMap& settings_map2_ret = it->second;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 EXPECT_EQ(actual_address, address); 1300 EXPECT_EQ(actual_address, address);
1201 1301
1202 impl_.Clear(); 1302 impl_.Clear();
1203 1303
1204 EXPECT_FALSE(impl_.GetSupportsQuic(&address)); 1304 EXPECT_FALSE(impl_.GetSupportsQuic(&address));
1205 } 1305 }
1206 1306
1207 typedef HttpServerPropertiesImplTest ServerNetworkStatsServerPropertiesTest; 1307 typedef HttpServerPropertiesImplTest ServerNetworkStatsServerPropertiesTest;
1208 1308
1209 TEST_F(ServerNetworkStatsServerPropertiesTest, Initialize) { 1309 TEST_F(ServerNetworkStatsServerPropertiesTest, Initialize) {
1210 HostPortPair google_server("www.google.com", 443); 1310 url::SchemeHostPort google_server("https", "www.google.com", 443);
1211 1311
1212 // Check by initializing empty ServerNetworkStats. 1312 // Check by initializing empty ServerNetworkStats.
1213 ServerNetworkStatsMap init_server_network_stats_map( 1313 ServerNetworkStatsMap init_server_network_stats_map(
1214 ServerNetworkStatsMap::NO_AUTO_EVICT); 1314 ServerNetworkStatsMap::NO_AUTO_EVICT);
1215 impl_.InitializeServerNetworkStats(&init_server_network_stats_map); 1315 impl_.InitializeServerNetworkStats(&init_server_network_stats_map);
1216 const ServerNetworkStats* stats = impl_.GetServerNetworkStats(google_server); 1316 const ServerNetworkStats* stats = impl_.GetServerNetworkStats(google_server);
1217 EXPECT_EQ(NULL, stats); 1317 EXPECT_EQ(NULL, stats);
1218 1318
1219 // Check by initializing with www.google.com:443. 1319 // Check by initializing with www.google.com:443.
1220 ServerNetworkStats stats_google; 1320 ServerNetworkStats stats_google;
1221 stats_google.srtt = base::TimeDelta::FromMicroseconds(10); 1321 stats_google.srtt = base::TimeDelta::FromMicroseconds(10);
1222 stats_google.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(100); 1322 stats_google.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(100);
1223 init_server_network_stats_map.Put(google_server, stats_google); 1323 init_server_network_stats_map.Put(google_server, stats_google);
1224 impl_.InitializeServerNetworkStats(&init_server_network_stats_map); 1324 impl_.InitializeServerNetworkStats(&init_server_network_stats_map);
1225 1325
1226 // Verify data for www.google.com:443. 1326 // Verify data for www.google.com:443.
1227 ASSERT_EQ(1u, impl_.server_network_stats_map().size()); 1327 ASSERT_EQ(1u, impl_.server_network_stats_map().size());
1228 EXPECT_EQ(stats_google, *(impl_.GetServerNetworkStats(google_server))); 1328 EXPECT_EQ(stats_google, *(impl_.GetServerNetworkStats(google_server)));
1229 1329
1230 // Test recency order and overwriting of data. 1330 // Test recency order and overwriting of data.
1231 // 1331 //
1232 // |docs_server| has a ServerNetworkStats, which will be overwritten by 1332 // |docs_server| has a ServerNetworkStats, which will be overwritten by
1233 // InitializeServerNetworkStats(), because |server_network_stats_map| has an 1333 // InitializeServerNetworkStats(), because |server_network_stats_map| has an
1234 // entry for |docs_server|. 1334 // entry for |docs_server|.
1235 HostPortPair docs_server("docs.google.com", 443); 1335 url::SchemeHostPort docs_server("https", "docs.google.com", 443);
1236 ServerNetworkStats stats_docs; 1336 ServerNetworkStats stats_docs;
1237 stats_docs.srtt = base::TimeDelta::FromMicroseconds(20); 1337 stats_docs.srtt = base::TimeDelta::FromMicroseconds(20);
1238 stats_docs.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(200); 1338 stats_docs.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(200);
1239 // Recency order will be |docs_server| and |google_server|. 1339 // Recency order will be |docs_server| and |google_server|.
1240 impl_.SetServerNetworkStats(docs_server, stats_docs); 1340 impl_.SetServerNetworkStats(docs_server, stats_docs);
1241 1341
1242 // Prepare |server_network_stats_map| to be loaded by 1342 // Prepare |server_network_stats_map| to be loaded by
1243 // InitializeServerNetworkStats(). 1343 // InitializeServerNetworkStats().
1244 ServerNetworkStatsMap server_network_stats_map( 1344 ServerNetworkStatsMap server_network_stats_map(
1245 ServerNetworkStatsMap::NO_AUTO_EVICT); 1345 ServerNetworkStatsMap::NO_AUTO_EVICT);
1246 1346
1247 // Change the values for |docs_server|. 1347 // Change the values for |docs_server|.
1248 ServerNetworkStats new_stats_docs; 1348 ServerNetworkStats new_stats_docs;
1249 new_stats_docs.srtt = base::TimeDelta::FromMicroseconds(25); 1349 new_stats_docs.srtt = base::TimeDelta::FromMicroseconds(25);
1250 new_stats_docs.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(250); 1350 new_stats_docs.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(250);
1251 server_network_stats_map.Put(docs_server, new_stats_docs); 1351 server_network_stats_map.Put(docs_server, new_stats_docs);
1252 // Add data for mail.google.com:443. 1352 // Add data for mail.google.com:443.
1253 HostPortPair mail_server("mail.google.com", 443); 1353 url::SchemeHostPort mail_server("https", "mail.google.com", 443);
1254 ServerNetworkStats stats_mail; 1354 ServerNetworkStats stats_mail;
1255 stats_mail.srtt = base::TimeDelta::FromMicroseconds(30); 1355 stats_mail.srtt = base::TimeDelta::FromMicroseconds(30);
1256 stats_mail.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(300); 1356 stats_mail.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(300);
1257 server_network_stats_map.Put(mail_server, stats_mail); 1357 server_network_stats_map.Put(mail_server, stats_mail);
1258 1358
1259 // Recency order will be |docs_server|, |google_server| and |mail_server|. 1359 // Recency order will be |docs_server|, |google_server| and |mail_server|.
1260 impl_.InitializeServerNetworkStats(&server_network_stats_map); 1360 impl_.InitializeServerNetworkStats(&server_network_stats_map);
1261 1361
1262 const ServerNetworkStatsMap& map = impl_.server_network_stats_map(); 1362 const ServerNetworkStatsMap& map = impl_.server_network_stats_map();
1263 ASSERT_EQ(3u, map.size()); 1363 ASSERT_EQ(3u, map.size());
1264 ServerNetworkStatsMap::const_iterator map_it = map.begin(); 1364 ServerNetworkStatsMap::const_iterator map_it = map.begin();
1265 1365
1266 EXPECT_TRUE(map_it->first.Equals(docs_server)); 1366 EXPECT_TRUE(map_it->first.Equals(docs_server));
1267 EXPECT_EQ(new_stats_docs, map_it->second); 1367 EXPECT_EQ(new_stats_docs, map_it->second);
1268 ++map_it; 1368 ++map_it;
1269 EXPECT_TRUE(map_it->first.Equals(google_server)); 1369 EXPECT_TRUE(map_it->first.Equals(google_server));
1270 EXPECT_EQ(stats_google, map_it->second); 1370 EXPECT_EQ(stats_google, map_it->second);
1271 ++map_it; 1371 ++map_it;
1272 EXPECT_TRUE(map_it->first.Equals(mail_server)); 1372 EXPECT_TRUE(map_it->first.Equals(mail_server));
1273 EXPECT_EQ(stats_mail, map_it->second); 1373 EXPECT_EQ(stats_mail, map_it->second);
1274 } 1374 }
1275 1375
1276 TEST_F(ServerNetworkStatsServerPropertiesTest, SetServerNetworkStats) { 1376 TEST_F(ServerNetworkStatsServerPropertiesTest, SetServerNetworkStats) {
1277 HostPortPair foo_server("foo", 80); 1377 url::SchemeHostPort foo_http_server("http", "foo", 443);
1278 const ServerNetworkStats* stats = impl_.GetServerNetworkStats(foo_server); 1378 url::SchemeHostPort foo_https_server("https", "foo", 443);
1279 EXPECT_EQ(NULL, stats); 1379 EXPECT_EQ(NULL, impl_.GetServerNetworkStats(foo_http_server));
1380 EXPECT_EQ(NULL, impl_.GetServerNetworkStats(foo_https_server));
1280 1381
1281 ServerNetworkStats stats1; 1382 ServerNetworkStats stats1;
1282 stats1.srtt = base::TimeDelta::FromMicroseconds(10); 1383 stats1.srtt = base::TimeDelta::FromMicroseconds(10);
1283 stats1.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(100); 1384 stats1.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(100);
1284 impl_.SetServerNetworkStats(foo_server, stats1); 1385 impl_.SetServerNetworkStats(foo_http_server, stats1);
1285 1386
1286 const ServerNetworkStats* stats2 = impl_.GetServerNetworkStats(foo_server); 1387 const ServerNetworkStats* stats2 =
1388 impl_.GetServerNetworkStats(foo_http_server);
1287 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); 1389 EXPECT_EQ(10, stats2->srtt.ToInternalValue());
1288 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); 1390 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond());
1391 // Https server should have nothing set for server network stats.
1392 EXPECT_EQ(NULL, impl_.GetServerNetworkStats(foo_https_server));
1289 1393
1290 impl_.Clear(); 1394 impl_.Clear();
1291 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); 1395 EXPECT_EQ(NULL, impl_.GetServerNetworkStats(foo_http_server));
1292 EXPECT_EQ(NULL, stats3); 1396 EXPECT_EQ(NULL, impl_.GetServerNetworkStats(foo_https_server));
1293 } 1397 }
1294 1398
1295 typedef HttpServerPropertiesImplTest QuicServerInfoServerPropertiesTest; 1399 typedef HttpServerPropertiesImplTest QuicServerInfoServerPropertiesTest;
1296 1400
1297 TEST_F(QuicServerInfoServerPropertiesTest, Initialize) { 1401 TEST_F(QuicServerInfoServerPropertiesTest, Initialize) {
1298 HostPortPair google_server("www.google.com", 443); 1402 HostPortPair google_server("www.google.com", 443);
1299 QuicServerId google_quic_server_id(google_server, PRIVACY_MODE_ENABLED); 1403 QuicServerId google_quic_server_id(google_server, PRIVACY_MODE_ENABLED);
1300 1404
1301 EXPECT_EQ(QuicServerInfoMap::NO_AUTO_EVICT, 1405 EXPECT_EQ(QuicServerInfoMap::NO_AUTO_EVICT,
1302 impl_.quic_server_info_map().max_size()); 1406 impl_.quic_server_info_map().max_size());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1497 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1394 1498
1395 impl_.Clear(); 1499 impl_.Clear();
1396 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1500 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1397 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1501 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1398 } 1502 }
1399 1503
1400 } // namespace 1504 } // namespace
1401 1505
1402 } // namespace net 1506 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698