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

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

Issue 1572753003: QUIC - Allow cronet apps to specify how many server configs are to be (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments in Patch set 4 Created 4 years, 11 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
« no previous file with comments | « net/http/http_server_properties_manager.cc ('k') | net/quic/quic_stream_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 GetParam()); 269 GetParam());
270 http_server_properties_dict->SetWithoutPathExpansion("servers", 270 http_server_properties_dict->SetWithoutPathExpansion("servers",
271 servers_dict); 271 servers_dict);
272 } 272 }
273 base::DictionaryValue* supports_quic = new base::DictionaryValue; 273 base::DictionaryValue* supports_quic = new base::DictionaryValue;
274 supports_quic->SetBoolean("used_quic", true); 274 supports_quic->SetBoolean("used_quic", true);
275 supports_quic->SetString("address", "127.0.0.1"); 275 supports_quic->SetString("address", "127.0.0.1");
276 http_server_properties_dict->SetWithoutPathExpansion("supports_quic", 276 http_server_properties_dict->SetWithoutPathExpansion("supports_quic",
277 supports_quic); 277 supports_quic);
278 278
279 // Set quic_server_info for www.google.com:80 and mail.google.com:80. 279 // Set quic_server_info for www.google.com:80, mail.google.com:80 and
280 // play.google.com:80 and verify the MRU.
281 http_server_props_manager_->SetMaxServerConfigsStoredInProperties(3);
280 base::DictionaryValue* quic_servers_dict = new base::DictionaryValue; 282 base::DictionaryValue* quic_servers_dict = new base::DictionaryValue;
281 base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue; 283 base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue;
282 std::string quic_server_info1("quic_server_info1"); 284 std::string quic_server_info1("quic_server_info1");
283 quic_server_pref_dict1->SetStringWithoutPathExpansion("server_info", 285 quic_server_pref_dict1->SetStringWithoutPathExpansion("server_info",
284 quic_server_info1); 286 quic_server_info1);
285 base::DictionaryValue* quic_server_pref_dict2 = new base::DictionaryValue; 287 base::DictionaryValue* quic_server_pref_dict2 = new base::DictionaryValue;
286 std::string quic_server_info2("quic_server_info2"); 288 std::string quic_server_info2("quic_server_info2");
287 quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info", 289 quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info",
288 quic_server_info2); 290 quic_server_info2);
291 base::DictionaryValue* quic_server_pref_dict3 = new base::DictionaryValue;
292 std::string quic_server_info3("quic_server_info3");
293 quic_server_pref_dict3->SetStringWithoutPathExpansion("server_info",
294 quic_server_info3);
289 // Set the quic_server_info1 for www.google.com server. 295 // Set the quic_server_info1 for www.google.com server.
290 QuicServerId google_quic_server_id("www.google.com", 80); 296 QuicServerId google_quic_server_id("www.google.com", 80);
291 quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(), 297 quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(),
292 quic_server_pref_dict1); 298 quic_server_pref_dict1);
293 // Set the quic_server_info2 for mail.google.com server. 299 // Set the quic_server_info2 for mail.google.com server.
294 QuicServerId mail_quic_server_id("mail.google.com", 80); 300 QuicServerId mail_quic_server_id("mail.google.com", 80);
295 quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(), 301 quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(),
296 quic_server_pref_dict2); 302 quic_server_pref_dict2);
303 // Set the quic_server_info3 for play.google.com server.
304 QuicServerId play_quic_server_id("play.google.com", 80);
305 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(),
306 quic_server_pref_dict3);
297 http_server_properties_dict->SetWithoutPathExpansion("quic_servers", 307 http_server_properties_dict->SetWithoutPathExpansion("quic_servers",
298 quic_servers_dict); 308 quic_servers_dict);
299 309
300 // Set the same value for kHttpServerProperties multiple times. 310 // Set the same value for kHttpServerProperties multiple times.
301 pref_service_.SetManagedPref(kTestHttpServerProperties, 311 pref_service_.SetManagedPref(kTestHttpServerProperties,
302 http_server_properties_dict); 312 http_server_properties_dict);
303 base::DictionaryValue* http_server_properties_dict2 = 313 base::DictionaryValue* http_server_properties_dict2 =
304 http_server_properties_dict->DeepCopy(); 314 http_server_properties_dict->DeepCopy();
305 pref_service_.SetManagedPref(kTestHttpServerProperties, 315 pref_service_.SetManagedPref(kTestHttpServerProperties,
306 http_server_properties_dict2); 316 http_server_properties_dict2);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); 378 EXPECT_EQ(10, stats2->srtt.ToInternalValue());
369 const ServerNetworkStats* stats3 = 379 const ServerNetworkStats* stats3 =
370 http_server_props_manager_->GetServerNetworkStats(mail_server); 380 http_server_props_manager_->GetServerNetworkStats(mail_server);
371 EXPECT_EQ(20, stats3->srtt.ToInternalValue()); 381 EXPECT_EQ(20, stats3->srtt.ToInternalValue());
372 382
373 // Verify QuicServerInfo. 383 // Verify QuicServerInfo.
374 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( 384 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo(
375 google_quic_server_id)); 385 google_quic_server_id));
376 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( 386 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
377 mail_quic_server_id)); 387 mail_quic_server_id));
388 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
389 play_quic_server_id));
390
391 // Verify the MRU order.
392 http_server_props_manager_->SetMaxServerConfigsStoredInProperties(2);
393 EXPECT_EQ(nullptr, http_server_props_manager_->GetQuicServerInfo(
394 google_quic_server_id));
395 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
396 mail_quic_server_id));
397 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
398 play_quic_server_id));
378 } 399 }
379 400
380 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { 401 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
381 ExpectCacheUpdate(); 402 ExpectCacheUpdate();
382 // The prefs are automaticalls updated in the case corruption is detected. 403 // The prefs are automaticalls updated in the case corruption is detected.
383 ExpectPrefsUpdate(); 404 ExpectPrefsUpdate();
384 ExpectScheduleUpdatePrefsOnNetworkThread(); 405 ExpectScheduleUpdatePrefsOnNetworkThread();
385 406
386 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; 407 base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
387 408
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // Shutdown comes before the task is executed. 1328 // Shutdown comes before the task is executed.
1308 http_server_props_manager_->ShutdownOnPrefThread(); 1329 http_server_props_manager_->ShutdownOnPrefThread();
1309 // Run the task after shutdown, but before deletion. 1330 // Run the task after shutdown, but before deletion.
1310 base::RunLoop().RunUntilIdle(); 1331 base::RunLoop().RunUntilIdle();
1311 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); 1332 Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
1312 http_server_props_manager_.reset(); 1333 http_server_props_manager_.reset();
1313 base::RunLoop().RunUntilIdle(); 1334 base::RunLoop().RunUntilIdle();
1314 } 1335 }
1315 1336
1316 } // namespace net 1337 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.cc ('k') | net/quic/quic_stream_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698