| OLD | NEW |
| 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 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 impl_.SetAlternativeServices( | 590 impl_.SetAlternativeServices( |
| 591 canonical_server, | 591 canonical_server, |
| 592 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); | 592 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); |
| 593 | 593 |
| 594 // There should still be no alternative service assigned to | 594 // There should still be no alternative service assigned to |
| 595 // |canonical_server|. | 595 // |canonical_server|. |
| 596 alternative_service_vector = impl_.GetAlternativeServices(canonical_server); | 596 alternative_service_vector = impl_.GetAlternativeServices(canonical_server); |
| 597 ASSERT_TRUE(alternative_service_vector.empty()); | 597 ASSERT_TRUE(alternative_service_vector.empty()); |
| 598 } | 598 } |
| 599 | 599 |
| 600 TEST_F(AlternateProtocolServerPropertiesTest, ClearServerWithCanonical) { |
| 601 url::SchemeHostPort server("https", "foo.c.youtube.com", 443); |
| 602 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); |
| 603 const AlternativeService alternative_service(QUIC, "", 443); |
| 604 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 605 const AlternativeServiceInfo alternative_service_info(alternative_service, |
| 606 expiration); |
| 607 |
| 608 impl_.SetAlternativeServices( |
| 609 canonical_server, |
| 610 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); |
| 611 |
| 612 // Make sure the canonical service is returned for the other server. |
| 613 const AlternativeServiceVector alternative_service_vector = |
| 614 impl_.GetAlternativeServices(server); |
| 615 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 616 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); |
| 617 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 618 |
| 619 // Now clear the alternatives for the other server and make sure it stays |
| 620 // cleared. |
| 621 // GetAlternativeServices() should remove this key from |
| 622 // |alternative_service_map_|, and SetAlternativeServices() should not crash. |
| 623 impl_.SetAlternativeServices(server, AlternativeServiceInfoVector()); |
| 624 |
| 625 ASSERT_TRUE(impl_.GetAlternativeServices(server).empty()); |
| 626 } |
| 627 |
| 600 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) { | 628 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) { |
| 601 url::SchemeHostPort test_server1("http", "foo1", 80); | 629 url::SchemeHostPort test_server1("http", "foo1", 80); |
| 602 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443); | 630 const AlternativeService alternative_service1(NPN_SPDY_3_1, "foo1", 443); |
| 603 SetAlternativeService(test_server1, alternative_service1); | 631 SetAlternativeService(test_server1, alternative_service1); |
| 604 url::SchemeHostPort test_server2("http", "foo2", 80); | 632 url::SchemeHostPort test_server2("http", "foo2", 80); |
| 605 const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234); | 633 const AlternativeService alternative_service2(NPN_HTTP_2, "foo2", 1234); |
| 606 SetAlternativeService(test_server2, alternative_service2); | 634 SetAlternativeService(test_server2, alternative_service2); |
| 607 | 635 |
| 608 const AlternativeServiceMap& map = impl_.alternative_service_map(); | 636 const AlternativeServiceMap& map = impl_.alternative_service_map(); |
| 609 AlternativeServiceMap::const_iterator it = map.begin(); | 637 AlternativeServiceMap::const_iterator it = map.begin(); |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); | 1524 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); |
| 1497 | 1525 |
| 1498 impl_.Clear(); | 1526 impl_.Clear(); |
| 1499 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); | 1527 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); |
| 1500 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); | 1528 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); |
| 1501 } | 1529 } |
| 1502 | 1530 |
| 1503 } // namespace | 1531 } // namespace |
| 1504 | 1532 |
| 1505 } // namespace net | 1533 } // namespace net |
| OLD | NEW |