| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 TEST_F(AlternateProtocolServerPropertiesTest, DefaultProbabilityExcluded) { | 259 TEST_F(AlternateProtocolServerPropertiesTest, DefaultProbabilityExcluded) { |
| 260 HostPortPair test_host_port_pair("foo", 80); | 260 HostPortPair test_host_port_pair("foo", 80); |
| 261 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); | 261 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); |
| 262 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.99); | 262 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.99); |
| 263 | 263 |
| 264 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); | 264 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 TEST_F(AlternateProtocolServerPropertiesTest, Probability) { | 267 TEST_F(AlternateProtocolServerPropertiesTest, Probability) { |
| 268 impl_.SetAlternateProtocolProbabilityThreshold(0.25); | 268 impl_.SetAlternativeServiceProbabilityThreshold(0.25); |
| 269 | 269 |
| 270 HostPortPair test_host_port_pair("foo", 80); | 270 HostPortPair test_host_port_pair("foo", 80); |
| 271 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); | 271 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); |
| 272 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); | 272 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); |
| 273 EXPECT_TRUE(HasAlternativeService(test_host_port_pair)); | 273 EXPECT_TRUE(HasAlternativeService(test_host_port_pair)); |
| 274 | 274 |
| 275 AlternativeServiceMap::const_iterator it = | 275 AlternativeServiceMap::const_iterator it = |
| 276 impl_.alternative_service_map().Peek(test_host_port_pair); | 276 impl_.alternative_service_map().Peek(test_host_port_pair); |
| 277 ASSERT_TRUE(it != impl_.alternative_service_map().end()); | 277 ASSERT_TRUE(it != impl_.alternative_service_map().end()); |
| 278 EXPECT_EQ(443, it->second.alternative_service.port); | 278 EXPECT_EQ(443, it->second.alternative_service.port); |
| 279 EXPECT_EQ(NPN_SPDY_4, it->second.alternative_service.protocol); | 279 EXPECT_EQ(NPN_SPDY_4, it->second.alternative_service.protocol); |
| 280 EXPECT_EQ(0.5, it->second.probability); | 280 EXPECT_EQ(0.5, it->second.probability); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) { | 283 TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) { |
| 284 impl_.SetAlternateProtocolProbabilityThreshold(0.75); | 284 impl_.SetAlternativeServiceProbabilityThreshold(0.75); |
| 285 | 285 |
| 286 HostPortPair test_host_port_pair("foo", 80); | 286 HostPortPair test_host_port_pair("foo", 80); |
| 287 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); | 287 const AlternativeService alternative_service(NPN_SPDY_4, "foo", 443); |
| 288 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); | 288 impl_.SetAlternativeService(test_host_port_pair, alternative_service, 0.5); |
| 289 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); | 289 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { | 292 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { |
| 293 HostPortPair test_host_port_pair1("foo1", 80); | 293 HostPortPair test_host_port_pair1("foo1", 80); |
| 294 const AlternativeService alternative_service1(NPN_SPDY_4, "foo1", 443); | 294 const AlternativeService alternative_service1(NPN_SPDY_4, "foo1", 443); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 1.0); | 426 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 1.0); |
| 427 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); | 427 ASSERT_TRUE(HasAlternativeService(test_host_port_pair)); |
| 428 const AlternativeService alternative_service = | 428 const AlternativeService alternative_service = |
| 429 impl_.GetAlternativeService(test_host_port_pair); | 429 impl_.GetAlternativeService(test_host_port_pair); |
| 430 EXPECT_EQ(canonical_altsvc.protocol, alternative_service.protocol); | 430 EXPECT_EQ(canonical_altsvc.protocol, alternative_service.protocol); |
| 431 EXPECT_EQ(test_host_port_pair.host(), alternative_service.host); | 431 EXPECT_EQ(test_host_port_pair.host(), alternative_service.host); |
| 432 EXPECT_EQ(canonical_altsvc.port, alternative_service.port); | 432 EXPECT_EQ(canonical_altsvc.port, alternative_service.port); |
| 433 } | 433 } |
| 434 | 434 |
| 435 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) { | 435 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBelowThreshold) { |
| 436 impl_.SetAlternateProtocolProbabilityThreshold(0.02); | 436 impl_.SetAlternativeServiceProbabilityThreshold(0.02); |
| 437 | 437 |
| 438 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 438 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
| 439 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 439 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
| 440 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234); | 440 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234); |
| 441 | 441 |
| 442 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 0.01); | 442 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 0.01); |
| 443 EXPECT_FALSE(HasAlternativeService(canonical_port_pair)); | 443 EXPECT_FALSE(HasAlternativeService(canonical_port_pair)); |
| 444 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); | 444 EXPECT_FALSE(HasAlternativeService(test_host_port_pair)); |
| 445 } | 445 } |
| 446 | 446 |
| 447 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) { | 447 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalAboveThreshold) { |
| 448 impl_.SetAlternateProtocolProbabilityThreshold(0.02); | 448 impl_.SetAlternativeServiceProbabilityThreshold(0.02); |
| 449 | 449 |
| 450 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 450 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
| 451 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 451 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
| 452 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234); | 452 AlternativeService canonical_altsvc(QUIC, "bar.c.youtube.com", 1234); |
| 453 | 453 |
| 454 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 0.03); | 454 impl_.SetAlternativeService(canonical_port_pair, canonical_altsvc, 0.03); |
| 455 EXPECT_TRUE(HasAlternativeService(canonical_port_pair)); | 455 EXPECT_TRUE(HasAlternativeService(canonical_port_pair)); |
| 456 EXPECT_TRUE(HasAlternativeService(test_host_port_pair)); | 456 EXPECT_TRUE(HasAlternativeService(test_host_port_pair)); |
| 457 } | 457 } |
| 458 | 458 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); | 788 EXPECT_EQ(100, stats2->bandwidth_estimate.ToBitsPerSecond()); |
| 789 | 789 |
| 790 impl_.Clear(); | 790 impl_.Clear(); |
| 791 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); | 791 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); |
| 792 EXPECT_EQ(NULL, stats3); | 792 EXPECT_EQ(NULL, stats3); |
| 793 } | 793 } |
| 794 | 794 |
| 795 } // namespace | 795 } // namespace |
| 796 | 796 |
| 797 } // namespace net | 797 } // namespace net |
| OLD | NEW |