| OLD | NEW |
| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); | 460 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); |
| 461 | 461 |
| 462 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 462 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 TEST_F(HttpServerPropertiesManagerTest, GetAlternativeService) { | 465 TEST_F(HttpServerPropertiesManagerTest, GetAlternativeService) { |
| 466 ExpectPrefsUpdate(); | 466 ExpectPrefsUpdate(); |
| 467 | 467 |
| 468 HostPortPair spdy_server_mail("mail.google.com", 80); | 468 HostPortPair spdy_server_mail("mail.google.com", 80); |
| 469 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 469 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 470 http_server_props_manager_->SetAlternateProtocol(spdy_server_mail, 443, | 470 AlternativeService alternative_service(NPN_SPDY_3, "mail.google.com", 443); |
| 471 NPN_SPDY_3, 1.0); | 471 http_server_props_manager_->SetAlternativeService(spdy_server_mail, |
| 472 alternative_service, 1.0); |
| 472 | 473 |
| 473 // Run the task. | 474 // Run the task. |
| 474 base::RunLoop().RunUntilIdle(); | 475 base::RunLoop().RunUntilIdle(); |
| 475 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 476 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 476 | 477 |
| 477 const AlternativeService alternate_protocol = | 478 alternative_service = |
| 478 http_server_props_manager_->GetAlternativeService(spdy_server_mail); | 479 http_server_props_manager_->GetAlternativeService(spdy_server_mail); |
| 479 EXPECT_EQ(443, alternate_protocol.port); | 480 EXPECT_EQ(443, alternative_service.port); |
| 480 EXPECT_EQ(NPN_SPDY_3, alternate_protocol.protocol); | 481 EXPECT_EQ(NPN_SPDY_3, alternative_service.protocol); |
| 481 } | 482 } |
| 482 | 483 |
| 483 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { | 484 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { |
| 484 ExpectPrefsUpdate(); | 485 ExpectPrefsUpdate(); |
| 485 | 486 |
| 486 IPAddressNumber address; | 487 IPAddressNumber address; |
| 487 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); | 488 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 488 | 489 |
| 489 IPAddressNumber actual_address; | 490 IPAddressNumber actual_address; |
| 490 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); | 491 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 516 const ServerNetworkStats* stats2 = | 517 const ServerNetworkStats* stats2 = |
| 517 http_server_props_manager_->GetServerNetworkStats(mail_server); | 518 http_server_props_manager_->GetServerNetworkStats(mail_server); |
| 518 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); | 519 EXPECT_EQ(10, stats2->srtt.ToInternalValue()); |
| 519 } | 520 } |
| 520 | 521 |
| 521 TEST_F(HttpServerPropertiesManagerTest, Clear) { | 522 TEST_F(HttpServerPropertiesManagerTest, Clear) { |
| 522 ExpectPrefsUpdate(); | 523 ExpectPrefsUpdate(); |
| 523 | 524 |
| 524 HostPortPair spdy_server_mail("mail.google.com", 443); | 525 HostPortPair spdy_server_mail("mail.google.com", 443); |
| 525 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 526 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
| 526 http_server_props_manager_->SetAlternateProtocol(spdy_server_mail, 443, | 527 AlternativeService alternative_service(NPN_SPDY_3, "mail.google.com", 443); |
| 527 NPN_SPDY_3, 1.0); | 528 http_server_props_manager_->SetAlternativeService(spdy_server_mail, |
| 529 alternative_service, 1.0); |
| 528 IPAddressNumber actual_address; | 530 IPAddressNumber actual_address; |
| 529 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); | 531 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
| 530 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 532 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| 531 ServerNetworkStats stats; | 533 ServerNetworkStats stats; |
| 532 stats.srtt = base::TimeDelta::FromMicroseconds(10); | 534 stats.srtt = base::TimeDelta::FromMicroseconds(10); |
| 533 http_server_props_manager_->SetServerNetworkStats(spdy_server_mail, stats); | 535 http_server_props_manager_->SetServerNetworkStats(spdy_server_mail, stats); |
| 534 | 536 |
| 535 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH; | 537 const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH; |
| 536 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST; | 538 const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST; |
| 537 const uint32 value1 = 31337; | 539 const uint32 value1 = 31337; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 IPAddressNumber address; | 645 IPAddressNumber address; |
| 644 ASSERT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); | 646 ASSERT_TRUE(http_server_props_manager_->GetSupportsQuic(&address)); |
| 645 EXPECT_EQ("127.0.0.1", IPAddressToString(address)); | 647 EXPECT_EQ("127.0.0.1", IPAddressToString(address)); |
| 646 } | 648 } |
| 647 | 649 |
| 648 TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) { | 650 TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) { |
| 649 const HostPortPair server_www("www.google.com", 80); | 651 const HostPortPair server_www("www.google.com", 80); |
| 650 const HostPortPair server_mail("mail.google.com", 80); | 652 const HostPortPair server_mail("mail.google.com", 80); |
| 651 | 653 |
| 652 // Set alternate protocol. | 654 // Set alternate protocol. |
| 653 http_server_props_manager_->SetAlternateProtocol(server_www, 443, NPN_SPDY_3, | 655 AlternativeService www_altsvc(NPN_SPDY_3, "www.google.com", 443); |
| 654 1.0); | 656 AlternativeService mail_altsvc(NPN_SPDY_3_1, "mail.google.com", 444); |
| 655 http_server_props_manager_->SetAlternateProtocol(server_mail, 444, | 657 http_server_props_manager_->SetAlternativeService(server_www, www_altsvc, |
| 656 NPN_SPDY_3_1, 0.2); | 658 1.0); |
| 659 http_server_props_manager_->SetAlternativeService(server_mail, mail_altsvc, |
| 660 0.2); |
| 657 | 661 |
| 658 // Set ServerNetworkStats. | 662 // Set ServerNetworkStats. |
| 659 ServerNetworkStats stats; | 663 ServerNetworkStats stats; |
| 660 stats.srtt = base::TimeDelta::FromInternalValue(42); | 664 stats.srtt = base::TimeDelta::FromInternalValue(42); |
| 661 http_server_props_manager_->SetServerNetworkStats(server_mail, stats); | 665 http_server_props_manager_->SetServerNetworkStats(server_mail, stats); |
| 662 | 666 |
| 663 // Set SupportsQuic. | 667 // Set SupportsQuic. |
| 664 IPAddressNumber actual_address; | 668 IPAddressNumber actual_address; |
| 665 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); | 669 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
| 666 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 670 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // Run the task after shutdown, but before deletion. | 775 // Run the task after shutdown, but before deletion. |
| 772 base::RunLoop().RunUntilIdle(); | 776 base::RunLoop().RunUntilIdle(); |
| 773 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 777 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 774 http_server_props_manager_.reset(); | 778 http_server_props_manager_.reset(); |
| 775 base::RunLoop().RunUntilIdle(); | 779 base::RunLoop().RunUntilIdle(); |
| 776 } | 780 } |
| 777 | 781 |
| 778 } // namespace | 782 } // namespace |
| 779 | 783 |
| 780 } // namespace net | 784 } // namespace net |
| OLD | NEW |