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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); | 358 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); |
359 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); | 359 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); |
360 | 360 |
361 const AlternativeService alternative_service2(NPN_SPDY_4, "foo", 1234); | 361 const AlternativeService alternative_service2(NPN_SPDY_4, "foo", 1234); |
362 impl_.SetAlternativeService(test_host_port_pair, alternative_service2, 1.0); | 362 impl_.SetAlternativeService(test_host_port_pair, alternative_service2, 1.0); |
363 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); | 363 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); |
364 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service2)); | 364 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service2)); |
365 EXPECT_EQ(1234, impl_.GetAlternativeService(test_host_port_pair).port); | 365 EXPECT_EQ(1234, impl_.GetAlternativeService(test_host_port_pair).port); |
366 } | 366 } |
367 | 367 |
| 368 // A broken alternative service in the mapping carries meaningful information, |
| 369 // therefore it should not be ignored by SetAlternativeService(). In |
| 370 // particular, an alternative service mapped to an origin shadows alternative |
| 371 // services of canonical hosts. |
| 372 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) { |
| 373 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
| 374 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
| 375 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234); |
| 376 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 1.0); |
| 377 EXPECT_TRUE(impl_.GetAlternativeService(test_host_port_pair) == |
| 378 canonical_altsvc); |
| 379 |
| 380 const AlternativeService broken_alternative_service(NPN_SPDY_4, "foo", 443); |
| 381 impl_.MarkAlternativeServiceBroken(broken_alternative_service); |
| 382 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); |
| 383 |
| 384 impl_.SetAlternativeService(test_host_port_pair, broken_alternative_service, |
| 385 1.0); |
| 386 ASSERT_EQ(broken_alternative_service, |
| 387 impl_.GetAlternativeService(test_host_port_pair)); |
| 388 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); |
| 389 } |
| 390 |
368 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { | 391 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { |
369 HostPortPair test_host_port_pair("foo", 80); | 392 HostPortPair test_host_port_pair("foo", 80); |
370 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); | 393 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); |
371 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 1.0); | 394 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 1.0); |
372 impl_.MarkAlternativeServiceBroken(alternative_service); | 395 impl_.MarkAlternativeServiceBroken(alternative_service); |
373 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); | 396 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); |
374 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); | 397 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); |
375 impl_.ClearAlternativeService(test_host_port_pair); | 398 impl_.ClearAlternativeService(test_host_port_pair); |
376 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); | 399 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); |
377 } | 400 } |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); | 812 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); |
790 | 813 |
791 impl_.Clear(); | 814 impl_.Clear(); |
792 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); | 815 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); |
793 EXPECT_EQ(NULL, stats3); | 816 EXPECT_EQ(NULL, stats3); |
794 } | 817 } |
795 | 818 |
796 } // namespace | 819 } // namespace |
797 | 820 |
798 } // namespace net | 821 } // namespace net |
OLD | NEW |