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

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: load all server configs from disk 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
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_->set_number_of_server_configs_stored_in_properties(
282 3);
280 base::DictionaryValue* quic_servers_dict = new base::DictionaryValue; 283 base::DictionaryValue* quic_servers_dict = new base::DictionaryValue;
281 base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue; 284 base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue;
282 std::string quic_server_info1("quic_server_info1"); 285 std::string quic_server_info1("quic_server_info1");
283 quic_server_pref_dict1->SetStringWithoutPathExpansion("server_info", 286 quic_server_pref_dict1->SetStringWithoutPathExpansion("server_info",
284 quic_server_info1); 287 quic_server_info1);
285 base::DictionaryValue* quic_server_pref_dict2 = new base::DictionaryValue; 288 base::DictionaryValue* quic_server_pref_dict2 = new base::DictionaryValue;
286 std::string quic_server_info2("quic_server_info2"); 289 std::string quic_server_info2("quic_server_info2");
287 quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info", 290 quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info",
288 quic_server_info2); 291 quic_server_info2);
292 base::DictionaryValue* quic_server_pref_dict3 = new base::DictionaryValue;
293 std::string quic_server_info3("quic_server_info3");
294 quic_server_pref_dict3->SetStringWithoutPathExpansion("server_info",
295 quic_server_info3);
289 // Set the quic_server_info1 for www.google.com server. 296 // Set the quic_server_info1 for www.google.com server.
290 QuicServerId google_quic_server_id("www.google.com", 80); 297 QuicServerId google_quic_server_id("www.google.com", 80);
291 quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(), 298 quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(),
292 quic_server_pref_dict1); 299 quic_server_pref_dict1);
293 // Set the quic_server_info2 for mail.google.com server. 300 // Set the quic_server_info2 for mail.google.com server.
294 QuicServerId mail_quic_server_id("mail.google.com", 80); 301 QuicServerId mail_quic_server_id("mail.google.com", 80);
295 quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(), 302 quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(),
296 quic_server_pref_dict2); 303 quic_server_pref_dict2);
304 // Set the quic_server_info3 for play.google.com server.
305 QuicServerId play_quic_server_id("play.google.com", 80);
306 quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(),
307 quic_server_pref_dict3);
297 http_server_properties_dict->SetWithoutPathExpansion("quic_servers", 308 http_server_properties_dict->SetWithoutPathExpansion("quic_servers",
298 quic_servers_dict); 309 quic_servers_dict);
299 310
300 // Set the same value for kHttpServerProperties multiple times. 311 // Set the same value for kHttpServerProperties multiple times.
301 pref_service_.SetManagedPref(kTestHttpServerProperties, 312 pref_service_.SetManagedPref(kTestHttpServerProperties,
302 http_server_properties_dict); 313 http_server_properties_dict);
303 base::DictionaryValue* http_server_properties_dict2 = 314 base::DictionaryValue* http_server_properties_dict2 =
304 http_server_properties_dict->DeepCopy(); 315 http_server_properties_dict->DeepCopy();
305 pref_service_.SetManagedPref(kTestHttpServerProperties, 316 pref_service_.SetManagedPref(kTestHttpServerProperties,
306 http_server_properties_dict2); 317 http_server_properties_dict2);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); 379 EXPECT_EQ(10, stats2->srtt.ToInternalValue());
369 const ServerNetworkStats* stats3 = 380 const ServerNetworkStats* stats3 =
370 http_server_props_manager_->GetServerNetworkStats(mail_server); 381 http_server_props_manager_->GetServerNetworkStats(mail_server);
371 EXPECT_EQ(20, stats3->srtt.ToInternalValue()); 382 EXPECT_EQ(20, stats3->srtt.ToInternalValue());
372 383
373 // Verify QuicServerInfo. 384 // Verify QuicServerInfo.
374 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo( 385 EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo(
375 google_quic_server_id)); 386 google_quic_server_id));
376 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( 387 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
377 mail_quic_server_id)); 388 mail_quic_server_id));
389 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
390 play_quic_server_id));
391
392 // Verify the MRU order.
393 http_server_props_manager_->set_number_of_server_configs_stored_in_properties(
394 2);
395 EXPECT_EQ(nullptr, http_server_props_manager_->GetQuicServerInfo(
396 google_quic_server_id));
397 EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
398 mail_quic_server_id));
399 EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
400 play_quic_server_id));
378 } 401 }
379 402
380 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { 403 TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
381 ExpectCacheUpdate(); 404 ExpectCacheUpdate();
382 // The prefs are automaticalls updated in the case corruption is detected. 405 // The prefs are automaticalls updated in the case corruption is detected.
383 ExpectPrefsUpdate(); 406 ExpectPrefsUpdate();
384 ExpectScheduleUpdatePrefsOnNetworkThread(); 407 ExpectScheduleUpdatePrefsOnNetworkThread();
385 408
386 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; 409 base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
387 410
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // Shutdown comes before the task is executed. 1330 // Shutdown comes before the task is executed.
1308 http_server_props_manager_->ShutdownOnPrefThread(); 1331 http_server_props_manager_->ShutdownOnPrefThread();
1309 // Run the task after shutdown, but before deletion. 1332 // Run the task after shutdown, but before deletion.
1310 base::RunLoop().RunUntilIdle(); 1333 base::RunLoop().RunUntilIdle();
1311 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); 1334 Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
1312 http_server_props_manager_.reset(); 1335 http_server_props_manager_.reset();
1313 base::RunLoop().RunUntilIdle(); 1336 base::RunLoop().RunUntilIdle();
1314 } 1337 }
1315 1338
1316 } // namespace net 1339 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698