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

Side by Side Diff: net/http/http_server_properties_impl_unittest.cc

Issue 2886273002: Change GetAlternativeServies to return alternative service infos. (Closed)
Patch Set: address comments in ps #3 Created 3 years, 7 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
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 }; 45 };
46 46
47 namespace { 47 namespace {
48 48
49 const int kMaxSupportsSpdyServerHosts = 500; 49 const int kMaxSupportsSpdyServerHosts = 500;
50 50
51 class HttpServerPropertiesImplTest : public testing::Test { 51 class HttpServerPropertiesImplTest : public testing::Test {
52 protected: 52 protected:
53 bool HasAlternativeService(const url::SchemeHostPort& origin) { 53 bool HasAlternativeService(const url::SchemeHostPort& origin) {
54 const AlternativeServiceVector alternative_service_vector = 54 const AlternativeServiceInfoVector alternative_service_info_vector =
55 impl_.GetAlternativeServices(origin); 55 impl_.GetAlternativeServiceInfos(origin);
56 return !alternative_service_vector.empty(); 56 return !alternative_service_info_vector.empty();
57 } 57 }
58 58
59 bool SetAlternativeService(const url::SchemeHostPort& origin, 59 bool SetAlternativeService(const url::SchemeHostPort& origin,
60 const AlternativeService& alternative_service) { 60 const AlternativeService& alternative_service) {
61 const base::Time expiration = 61 const base::Time expiration =
62 base::Time::Now() + base::TimeDelta::FromDays(1); 62 base::Time::Now() + base::TimeDelta::FromDays(1);
63 return impl_.SetAlternativeService(origin, alternative_service, expiration); 63 return impl_.SetAlternativeService(origin, alternative_service, expiration);
64 } 64 }
65 65
66 HttpServerPropertiesImpl impl_; 66 HttpServerPropertiesImpl impl_;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; 345 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest;
346 346
347 TEST_F(AlternateProtocolServerPropertiesTest, Basic) { 347 TEST_F(AlternateProtocolServerPropertiesTest, Basic) {
348 url::SchemeHostPort test_server("http", "foo", 80); 348 url::SchemeHostPort test_server("http", "foo", 80);
349 EXPECT_FALSE(HasAlternativeService(test_server)); 349 EXPECT_FALSE(HasAlternativeService(test_server));
350 350
351 AlternativeService alternative_service(kProtoHTTP2, "foo", 443); 351 AlternativeService alternative_service(kProtoHTTP2, "foo", 443);
352 SetAlternativeService(test_server, alternative_service); 352 SetAlternativeService(test_server, alternative_service);
353 const AlternativeServiceVector alternative_service_vector = 353 const AlternativeServiceInfoVector alternative_service_info_vector =
354 impl_.GetAlternativeServices(test_server); 354 impl_.GetAlternativeServiceInfos(test_server);
355 ASSERT_EQ(1u, alternative_service_vector.size()); 355 ASSERT_EQ(1u, alternative_service_info_vector.size());
356 EXPECT_EQ(alternative_service, alternative_service_vector[0]); 356 EXPECT_EQ(alternative_service,
357 alternative_service_info_vector[0].alternative_service);
357 358
358 impl_.Clear(); 359 impl_.Clear();
359 EXPECT_FALSE(HasAlternativeService(test_server)); 360 EXPECT_FALSE(HasAlternativeService(test_server));
360 } 361 }
361 362
362 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) { 363 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
363 AlternativeServiceInfoVector alternative_service_info_vector; 364 AlternativeServiceInfoVector alternative_service_info_vector;
364 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 365 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
365 // Same hostname, same port, TCP: should be ignored. 366 // Same hostname, same port, TCP: should be ignored.
366 AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 367 AlternativeServiceInfo alternative_service_info1(kProtoHTTP2, "foo", 443,
367 alternative_service_info_vector.push_back( 368 expiration);
368 AlternativeServiceInfo(alternative_service1, expiration)); 369 alternative_service_info_vector.push_back(alternative_service_info1);
369 // Different hostname: GetAlternativeServices should return this one. 370 // Different hostname: GetAlternativeServiceInfos should return this one.
370 AlternativeService alternative_service2(kProtoHTTP2, "bar", 443); 371 AlternativeServiceInfo alternative_service_info2(kProtoHTTP2, "bar", 443,
371 alternative_service_info_vector.push_back( 372 expiration);
372 AlternativeServiceInfo(alternative_service2, expiration)); 373 alternative_service_info_vector.push_back(alternative_service_info2);
373 // Different port: GetAlternativeServices should return this one too. 374 // Different port: GetAlternativeServiceInfos should return this one too.
374 AlternativeService alternative_service3(kProtoHTTP2, "foo", 80); 375 AlternativeServiceInfo alternative_service_info3(kProtoHTTP2, "foo", 80,
375 alternative_service_info_vector.push_back( 376 expiration);
376 AlternativeServiceInfo(alternative_service3, expiration)); 377 alternative_service_info_vector.push_back(alternative_service_info3);
377 // QUIC: GetAlternativeServices should return this one too. 378 // QUIC: GetAlternativeServices should return this one too.
378 AlternativeService alternative_service4(kProtoQUIC, "foo", 443); 379 AlternativeServiceInfo alternative_service_info4(kProtoQUIC, "foo", 443,
379 alternative_service_info_vector.push_back( 380 expiration);
380 AlternativeServiceInfo(alternative_service4, expiration)); 381 alternative_service_info_vector.push_back(alternative_service_info4);
381 382
382 url::SchemeHostPort test_server("https", "foo", 443); 383 url::SchemeHostPort test_server("https", "foo", 443);
383 impl_.SetAlternativeServices(test_server, alternative_service_info_vector); 384 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
384 385
385 const AlternativeServiceVector alternative_service_vector = 386 const AlternativeServiceInfoVector alternative_service_info_vector2 =
386 impl_.GetAlternativeServices(test_server); 387 impl_.GetAlternativeServiceInfos(test_server);
387 ASSERT_EQ(3u, alternative_service_vector.size()); 388 ASSERT_EQ(3u, alternative_service_info_vector2.size());
388 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 389 EXPECT_EQ(alternative_service_info2, alternative_service_info_vector2[0]);
389 EXPECT_EQ(alternative_service3, alternative_service_vector[1]); 390 EXPECT_EQ(alternative_service_info3, alternative_service_info_vector2[1]);
390 EXPECT_EQ(alternative_service4, alternative_service_vector[2]); 391 EXPECT_EQ(alternative_service_info4, alternative_service_info_vector2[2]);
391 } 392 }
392 393
393 TEST_F(AlternateProtocolServerPropertiesTest, Set) { 394 TEST_F(AlternateProtocolServerPropertiesTest, Set) {
394 // |test_server1| has an alternative service, which will not be 395 // |test_server1| has an alternative service, which will not be
395 // affected by SetAlternativeServiceServers(), because 396 // affected by SetAlternativeServiceServers(), because
396 // |alternative_service_map| does not have an entry for 397 // |alternative_service_map| does not have an entry for
397 // |test_server1|. 398 // |test_server1|.
398 url::SchemeHostPort test_server1("http", "foo1", 80); 399 url::SchemeHostPort test_server1("http", "foo1", 80);
399 const AlternativeService alternative_service1(kProtoHTTP2, "bar1", 443); 400 const AlternativeService alternative_service1(kProtoHTTP2, "bar1", 443);
400 const base::Time now = base::Time::Now(); 401 const base::Time now = base::Time::Now();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 "foo", 1234); 475 "foo", 1234);
475 SetAlternativeService(server, alternative_service_with_empty_hostname); 476 SetAlternativeService(server, alternative_service_with_empty_hostname);
476 impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname); 477 impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname);
477 478
478 AlternativeServiceMap alternative_service_map( 479 AlternativeServiceMap alternative_service_map(
479 AlternativeServiceMap::NO_AUTO_EVICT); 480 AlternativeServiceMap::NO_AUTO_EVICT);
480 impl_.SetAlternativeServiceServers(&alternative_service_map); 481 impl_.SetAlternativeServiceServers(&alternative_service_map);
481 482
482 EXPECT_TRUE( 483 EXPECT_TRUE(
483 impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname)); 484 impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname));
484 const AlternativeServiceVector alternative_service_vector = 485 const AlternativeServiceInfoVector alternative_service_info_vector =
485 impl_.GetAlternativeServices(server); 486 impl_.GetAlternativeServiceInfos(server);
486 ASSERT_EQ(1u, alternative_service_vector.size()); 487 ASSERT_EQ(1u, alternative_service_info_vector.size());
487 EXPECT_EQ(alternative_service_with_foo_hostname, 488 EXPECT_EQ(alternative_service_with_foo_hostname,
488 alternative_service_vector[0]); 489 alternative_service_info_vector[0].alternative_service);
489 } 490 }
490 491
491 // Regression test for https://crbug.com/516486: 492 // Regression test for https://crbug.com/516486:
492 // GetAlternativeServices() should remove |alternative_service_map_| elements 493 // GetAlternativeServiceInfos() should remove |alternative_service_map_|
493 // with empty value. 494 // elements with empty value.
494 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) { 495 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
495 url::SchemeHostPort server("https", "foo", 443); 496 url::SchemeHostPort server("https", "foo", 443);
496 const AlternativeService alternative_service(kProtoHTTP2, "bar", 443); 497 const AlternativeService alternative_service(kProtoHTTP2, "bar", 443);
497 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); 498 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
498 const AlternativeServiceInfo alternative_service_info(alternative_service, 499 const AlternativeServiceInfo alternative_service_info(alternative_service,
499 expiration); 500 expiration);
500 AlternativeServiceMap alternative_service_map( 501 AlternativeServiceMap alternative_service_map(
501 AlternativeServiceMap::NO_AUTO_EVICT); 502 AlternativeServiceMap::NO_AUTO_EVICT);
502 alternative_service_map.Put( 503 alternative_service_map.Put(
503 server, 504 server,
504 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 505 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
505 506
506 // Prepare |alternative_service_map_| with a single key that has a single 507 // Prepare |alternative_service_map_| with a single key that has a single
507 // AlternativeServiceInfo with identical hostname and port. 508 // AlternativeServiceInfo with identical hostname and port.
508 impl_.SetAlternativeServiceServers(&alternative_service_map); 509 impl_.SetAlternativeServiceServers(&alternative_service_map);
509 510
510 // GetAlternativeServices() should remove such AlternativeServiceInfo from 511 // GetAlternativeServiceInfos() should remove such AlternativeServiceInfo from
511 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector 512 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector
512 // corresponding to |server|. 513 // corresponding to |server|.
513 AlternativeServiceVector alternative_service_vector = 514 ASSERT_TRUE(impl_.GetAlternativeServiceInfos(server).empty());
514 impl_.GetAlternativeServices(server);
515 ASSERT_TRUE(alternative_service_vector.empty());
516 515
517 // GetAlternativeServices() should remove this key from 516 // GetAlternativeServiceInfos() should remove this key from
518 // |alternative_service_map_|, and SetAlternativeServices() should not crash. 517 // |alternative_service_map_|, and SetAlternativeServices() should not crash.
519 impl_.SetAlternativeServices( 518 impl_.SetAlternativeServices(
520 server, 519 server,
521 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 520 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
522 521
523 // There should still be no alternative service assigned to |server|. 522 // There should still be no alternative service assigned to |server|.
524 alternative_service_vector = impl_.GetAlternativeServices(server); 523 ASSERT_TRUE(impl_.GetAlternativeServiceInfos(server).empty());
525 ASSERT_TRUE(alternative_service_vector.empty());
526 } 524 }
527 525
528 // Regression test for https://crbug.com/516486 for the canonical host case. 526 // Regression test for https://crbug.com/516486 for the canonical host case.
529 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) { 527 TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
530 url::SchemeHostPort server("https", "foo.c.youtube.com", 443); 528 url::SchemeHostPort server("https", "foo.c.youtube.com", 443);
531 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 529 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
532 const AlternativeService alternative_service(kProtoHTTP2, "", 443); 530 const AlternativeService alternative_service(kProtoHTTP2, "", 443);
533 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); 531 base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
534 const AlternativeServiceInfo alternative_service_info(alternative_service, 532 const AlternativeServiceInfo alternative_service_info(alternative_service,
535 expiration); 533 expiration);
536 AlternativeServiceMap alternative_service_map( 534 AlternativeServiceMap alternative_service_map(
537 AlternativeServiceMap::NO_AUTO_EVICT); 535 AlternativeServiceMap::NO_AUTO_EVICT);
538 alternative_service_map.Put( 536 alternative_service_map.Put(
539 canonical_server, 537 canonical_server,
540 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 538 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
541 539
542 // Prepare |alternative_service_map_| with a single key that has a single 540 // Prepare |alternative_service_map_| with a single key that has a single
543 // AlternativeServiceInfo with identical hostname and port. 541 // AlternativeServiceInfo with identical hostname and port.
544 impl_.SetAlternativeServiceServers(&alternative_service_map); 542 impl_.SetAlternativeServiceServers(&alternative_service_map);
545 543
546 // GetAlternativeServices() should remove such AlternativeServiceInfo from 544 // GetAlternativeServiceInfos() should remove such AlternativeServiceInfo from
547 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector 545 // |alternative_service_map_|, emptying the AlternativeServiceInfoVector
548 // corresponding to |canonical_server|, even when looking up 546 // corresponding to |canonical_server|, even when looking up
549 // alternative services for |server|. 547 // alternative services for |server|.
550 AlternativeServiceVector alternative_service_vector = 548 ASSERT_TRUE(impl_.GetAlternativeServiceInfos(server).empty());
551 impl_.GetAlternativeServices(server);
552 ASSERT_TRUE(alternative_service_vector.empty());
553 549
554 // GetAlternativeServices() should remove this key from 550 // GetAlternativeServiceInfos() should remove this key from
555 // |alternative_service_map_|, and SetAlternativeServices() should not crash. 551 // |alternative_service_map_|, and SetAlternativeServices() should not crash.
556 impl_.SetAlternativeServices( 552 impl_.SetAlternativeServices(
557 canonical_server, 553 canonical_server,
558 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 554 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
559 555
560 // There should still be no alternative service assigned to 556 // There should still be no alternative service assigned to
561 // |canonical_server|. 557 // |canonical_server|.
562 alternative_service_vector = impl_.GetAlternativeServices(canonical_server); 558 ASSERT_TRUE(impl_.GetAlternativeServiceInfos(canonical_server).empty());
563 ASSERT_TRUE(alternative_service_vector.empty());
564 } 559 }
565 560
566 TEST_F(AlternateProtocolServerPropertiesTest, ClearServerWithCanonical) { 561 TEST_F(AlternateProtocolServerPropertiesTest, ClearServerWithCanonical) {
567 url::SchemeHostPort server("https", "foo.c.youtube.com", 443); 562 url::SchemeHostPort server("https", "foo.c.youtube.com", 443);
568 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 563 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
569 const AlternativeService alternative_service(kProtoQUIC, "", 443); 564 const AlternativeService alternative_service(kProtoQUIC, "", 443);
570 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 565 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
571 const AlternativeServiceInfo alternative_service_info(alternative_service, 566 const AlternativeServiceInfo alternative_service_info(alternative_service,
572 expiration); 567 expiration);
573 568
574 impl_.SetAlternativeServices( 569 impl_.SetAlternativeServices(
575 canonical_server, 570 canonical_server,
576 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); 571 AlternativeServiceInfoVector(/*size=*/1, alternative_service_info));
577 572
578 // Make sure the canonical service is returned for the other server. 573 // Make sure the canonical service is returned for the other server.
579 const AlternativeServiceVector alternative_service_vector = 574 const AlternativeServiceInfoVector alternative_service_info_vector =
580 impl_.GetAlternativeServices(server); 575 impl_.GetAlternativeServiceInfos(server);
581 ASSERT_EQ(1u, alternative_service_vector.size()); 576 ASSERT_EQ(1u, alternative_service_info_vector.size());
582 EXPECT_EQ(kProtoQUIC, alternative_service_vector[0].protocol); 577 EXPECT_EQ(kProtoQUIC,
583 EXPECT_EQ(443, alternative_service_vector[0].port); 578 alternative_service_info_vector[0].alternative_service.protocol);
579 EXPECT_EQ(443, alternative_service_info_vector[0].alternative_service.port);
584 580
585 // Now clear the alternatives for the other server and make sure it stays 581 // Now clear the alternatives for the other server and make sure it stays
586 // cleared. 582 // cleared.
587 // GetAlternativeServices() should remove this key from 583 // GetAlternativeServices() should remove this key from
588 // |alternative_service_map_|, and SetAlternativeServices() should not crash. 584 // |alternative_service_map_|, and SetAlternativeServices() should not crash.
589 impl_.SetAlternativeServices(server, AlternativeServiceInfoVector()); 585 impl_.SetAlternativeServices(server, AlternativeServiceInfoVector());
590 586
591 ASSERT_TRUE(impl_.GetAlternativeServices(server).empty()); 587 ASSERT_TRUE(impl_.GetAlternativeServiceInfos(server).empty());
592 } 588 }
593 589
594 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServices) { 590 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServiceInfos) {
595 url::SchemeHostPort test_server1("http", "foo1", 80); 591 url::SchemeHostPort test_server1("http", "foo1", 80);
596 const AlternativeService alternative_service1(kProtoHTTP2, "foo1", 443); 592 const AlternativeService alternative_service1(kProtoHTTP2, "foo1", 443);
597 SetAlternativeService(test_server1, alternative_service1); 593 SetAlternativeService(test_server1, alternative_service1);
598 url::SchemeHostPort test_server2("http", "foo2", 80); 594 url::SchemeHostPort test_server2("http", "foo2", 80);
599 const AlternativeService alternative_service2(kProtoHTTP2, "foo2", 1234); 595 const AlternativeService alternative_service2(kProtoHTTP2, "foo2", 1234);
600 SetAlternativeService(test_server2, alternative_service2); 596 SetAlternativeService(test_server2, alternative_service2);
601 597
602 const AlternativeServiceMap& map = impl_.alternative_service_map(); 598 const AlternativeServiceMap& map = impl_.alternative_service_map();
603 AlternativeServiceMap::const_iterator it = map.begin(); 599 AlternativeServiceMap::const_iterator it = map.begin();
604 EXPECT_TRUE(it->first.Equals(test_server2)); 600 EXPECT_TRUE(it->first.Equals(test_server2));
605 ASSERT_EQ(1u, it->second.size()); 601 ASSERT_EQ(1u, it->second.size());
606 EXPECT_EQ(alternative_service2, it->second[0].alternative_service); 602 EXPECT_EQ(alternative_service2, it->second[0].alternative_service);
607 603
608 const AlternativeServiceVector alternative_service_vector = 604 const AlternativeServiceInfoVector alternative_service_info_vector =
609 impl_.GetAlternativeServices(test_server1); 605 impl_.GetAlternativeServiceInfos(test_server1);
610 ASSERT_EQ(1u, alternative_service_vector.size()); 606 ASSERT_EQ(1u, alternative_service_info_vector.size());
611 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 607 EXPECT_EQ(alternative_service1,
608 alternative_service_info_vector[0].alternative_service);
612 609
613 // GetAlternativeServices should reorder the AlternateProtocol map. 610 // GetAlternativeServices should reorder the AlternateProtocol map.
614 it = map.begin(); 611 it = map.begin();
615 EXPECT_TRUE(it->first.Equals(test_server1)); 612 EXPECT_TRUE(it->first.Equals(test_server1));
616 ASSERT_EQ(1u, it->second.size()); 613 ASSERT_EQ(1u, it->second.size());
617 EXPECT_EQ(alternative_service1, it->second[0].alternative_service); 614 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
618 } 615 }
619 616
620 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { 617 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
621 url::SchemeHostPort test_server("http", "foo", 80); 618 url::SchemeHostPort test_server("http", "foo", 80);
622 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 619 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
623 SetAlternativeService(test_server, alternative_service1); 620 SetAlternativeService(test_server, alternative_service1);
624 AlternativeServiceVector alternative_service_vector = 621 AlternativeServiceInfoVector alternative_service_info_vector =
625 impl_.GetAlternativeServices(test_server); 622 impl_.GetAlternativeServiceInfos(test_server);
626 ASSERT_EQ(1u, alternative_service_vector.size()); 623 ASSERT_EQ(1u, alternative_service_info_vector.size());
627 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 624 EXPECT_EQ(alternative_service1,
625 alternative_service_info_vector[0].alternative_service);
628 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service1)); 626 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service1));
629 627
630 // GetAlternativeServices should return the broken alternative service. 628 // GetAlternativeServiceInfos should return the broken alternative service.
631 impl_.MarkAlternativeServiceBroken(alternative_service1); 629 impl_.MarkAlternativeServiceBroken(alternative_service1);
632 alternative_service_vector = impl_.GetAlternativeServices(test_server); 630 alternative_service_info_vector =
633 ASSERT_EQ(1u, alternative_service_vector.size()); 631 impl_.GetAlternativeServiceInfos(test_server);
634 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 632 ASSERT_EQ(1u, alternative_service_info_vector.size());
633 EXPECT_EQ(alternative_service1,
634 alternative_service_info_vector[0].alternative_service);
635 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 635 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
636 636
637 // SetAlternativeServices should add a broken alternative service to the map. 637 // SetAlternativeServices should add a broken alternative service to the map.
638 AlternativeServiceInfoVector alternative_service_info_vector; 638 AlternativeServiceInfoVector alternative_service_info_vector2;
639 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 639 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
640 alternative_service_info_vector.push_back( 640 alternative_service_info_vector2.push_back(
641 AlternativeServiceInfo(alternative_service1, expiration)); 641 AlternativeServiceInfo(alternative_service1, expiration));
642 const AlternativeService alternative_service2(kProtoHTTP2, "foo", 1234); 642 const AlternativeService alternative_service2(kProtoHTTP2, "foo", 1234);
643 alternative_service_info_vector.push_back( 643 alternative_service_info_vector2.push_back(
644 AlternativeServiceInfo(alternative_service2, expiration)); 644 AlternativeServiceInfo(alternative_service2, expiration));
645 impl_.SetAlternativeServices(test_server, alternative_service_info_vector); 645 impl_.SetAlternativeServices(test_server, alternative_service_info_vector2);
646 alternative_service_vector = impl_.GetAlternativeServices(test_server); 646 alternative_service_info_vector =
647 ASSERT_EQ(2u, alternative_service_vector.size()); 647 impl_.GetAlternativeServiceInfos(test_server);
648 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 648 ASSERT_EQ(2u, alternative_service_info_vector.size());
649 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); 649 EXPECT_EQ(alternative_service1,
650 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0])); 650 alternative_service_info_vector[0].alternative_service);
651 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service_vector[1])); 651 EXPECT_EQ(alternative_service2,
652 alternative_service_info_vector[1].alternative_service);
653 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
654 EXPECT_FALSE(impl_.IsAlternativeServiceBroken(alternative_service2));
652 655
653 // SetAlternativeService should add a broken alternative service to the map. 656 // SetAlternativeService should add a broken alternative service to the map.
654 SetAlternativeService(test_server, alternative_service1); 657 SetAlternativeService(test_server, alternative_service1);
655 alternative_service_vector = impl_.GetAlternativeServices(test_server); 658 alternative_service_info_vector =
656 ASSERT_EQ(1u, alternative_service_vector.size()); 659 impl_.GetAlternativeServiceInfos(test_server);
657 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); 660 ASSERT_EQ(1u, alternative_service_info_vector.size());
658 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service_vector[0])); 661 EXPECT_EQ(alternative_service1,
662 alternative_service_info_vector[0].alternative_service);
663 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
659 } 664 }
660 665
661 TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) { 666 TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {
662 AlternativeServiceInfoVector alternative_service_info_vector; 667 AlternativeServiceInfoVector alternative_service_info_vector;
663 base::Time now = base::Time::Now(); 668 base::Time now = base::Time::Now();
664 base::TimeDelta one_day = base::TimeDelta::FromDays(1); 669 base::TimeDelta one_day = base::TimeDelta::FromDays(1);
665 670
666 // First alternative service expired one day ago, should not be returned by 671 // First alternative service expired one day ago, should not be returned by
667 // GetAlternativeServices(). 672 // GetAlternativeServiceInfos().
668 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 673 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
669 alternative_service_info_vector.push_back( 674 alternative_service_info_vector.push_back(
670 AlternativeServiceInfo(alternative_service1, now - one_day)); 675 AlternativeServiceInfo(alternative_service1, now - one_day));
671 676
672 // Second alterrnative service will expire one day from now, should be 677 // Second alterrnative service will expire one day from now, should be
673 // returned by GetAlternativeSerices(). 678 // returned by GetAlternativeSerices().
674 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234); 679 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
675 alternative_service_info_vector.push_back( 680 alternative_service_info_vector.push_back(
676 AlternativeServiceInfo(alternative_service2, now + one_day)); 681 AlternativeServiceInfo(alternative_service2, now + one_day));
677 682
678 url::SchemeHostPort test_server("http", "foo", 80); 683 url::SchemeHostPort test_server("http", "foo", 80);
679 impl_.SetAlternativeServices(test_server, alternative_service_info_vector); 684 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
680 685
681 AlternativeServiceVector alternative_service_vector = 686 AlternativeServiceInfoVector alternative_service_info_vector2 =
682 impl_.GetAlternativeServices(test_server); 687 impl_.GetAlternativeServiceInfos(test_server);
683 ASSERT_EQ(1u, alternative_service_vector.size()); 688 ASSERT_EQ(1u, alternative_service_info_vector2.size());
684 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 689 EXPECT_EQ(alternative_service2,
690 alternative_service_info_vector2[0].alternative_service);
685 } 691 }
686 692
687 TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) { 693 TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {
688 AlternativeServiceInfoVector alternative_service_info_vector; 694 AlternativeServiceInfoVector alternative_service_info_vector;
689 base::Time now = base::Time::Now(); 695 base::Time now = base::Time::Now();
690 base::TimeDelta one_day = base::TimeDelta::FromDays(1); 696 base::TimeDelta one_day = base::TimeDelta::FromDays(1);
691 697
692 // First alternative service expired one day ago, should not be returned by 698 // First alternative service expired one day ago, should not be returned by
693 // GetAlternativeServices(). 699 // GetAlternativeServiceInfos().
694 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 700 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
695 alternative_service_info_vector.push_back( 701 alternative_service_info_vector.push_back(
696 AlternativeServiceInfo(alternative_service1, now - one_day)); 702 AlternativeServiceInfo(alternative_service1, now - one_day));
697 703
698 // Second alterrnative service will expire one day from now, should be 704 // Second alterrnative service will expire one day from now, should be
699 // returned by GetAlternativeSerices(). 705 // returned by GetAlternativeSerices().
700 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234); 706 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
701 alternative_service_info_vector.push_back( 707 alternative_service_info_vector.push_back(
702 AlternativeServiceInfo(alternative_service2, now + one_day)); 708 AlternativeServiceInfo(alternative_service2, now + one_day));
703 709
704 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 710 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
705 impl_.SetAlternativeServices(canonical_server, 711 impl_.SetAlternativeServices(canonical_server,
706 alternative_service_info_vector); 712 alternative_service_info_vector);
707 713
708 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 714 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
709 AlternativeServiceVector alternative_service_vector = 715 AlternativeServiceInfoVector alternative_service_info_vector2 =
710 impl_.GetAlternativeServices(test_server); 716 impl_.GetAlternativeServiceInfos(test_server);
711 ASSERT_EQ(1u, alternative_service_vector.size()); 717 ASSERT_EQ(1u, alternative_service_info_vector2.size());
712 EXPECT_EQ(alternative_service2, alternative_service_vector[0]); 718 EXPECT_EQ(alternative_service2,
719 alternative_service_info_vector2[0].alternative_service);
713 } 720 }
714 721
715 TEST_F(AlternateProtocolServerPropertiesTest, AlternativeServiceWithScheme) { 722 TEST_F(AlternateProtocolServerPropertiesTest, AlternativeServiceWithScheme) {
716 AlternativeServiceInfoVector alternative_service_info_vector; 723 AlternativeServiceInfoVector alternative_service_info_vector;
717 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 724 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
718 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 725 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
719 alternative_service_info_vector.push_back( 726 alternative_service_info_vector.push_back(
720 AlternativeServiceInfo(alternative_service1, expiration)); 727 AlternativeServiceInfo(alternative_service1, expiration));
721 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234); 728 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
722 alternative_service_info_vector.push_back( 729 alternative_service_info_vector.push_back(
723 AlternativeServiceInfo(alternative_service2, expiration)); 730 AlternativeServiceInfo(alternative_service2, expiration));
724 // Set Alt-Svc list for |http_server|. 731 // Set Alt-Svc list for |http_server|.
725 url::SchemeHostPort http_server("http", "foo", 80); 732 url::SchemeHostPort http_server("http", "foo", 80);
726 impl_.SetAlternativeServices(http_server, alternative_service_info_vector); 733 impl_.SetAlternativeServices(http_server, alternative_service_info_vector);
727 734
728 const net::AlternativeServiceMap& map = impl_.alternative_service_map(); 735 const net::AlternativeServiceMap& map = impl_.alternative_service_map();
729 net::AlternativeServiceMap::const_iterator it = map.begin(); 736 net::AlternativeServiceMap::const_iterator it = map.begin();
730 EXPECT_TRUE(it->first.Equals(http_server)); 737 EXPECT_TRUE(it->first.Equals(http_server));
731 ASSERT_EQ(2u, it->second.size()); 738 ASSERT_EQ(2u, it->second.size());
732 EXPECT_EQ(alternative_service1, it->second[0].alternative_service); 739 EXPECT_EQ(alternative_service1, it->second[0].alternative_service);
733 EXPECT_EQ(alternative_service2, it->second[1].alternative_service); 740 EXPECT_EQ(alternative_service2, it->second[1].alternative_service);
734 741
735 // Check Alt-Svc list should not be set for |https_server|. 742 // Check Alt-Svc list should not be set for |https_server|.
736 url::SchemeHostPort https_server("https", "foo", 80); 743 url::SchemeHostPort https_server("https", "foo", 80);
737 EXPECT_EQ(0u, impl_.GetAlternativeServices(https_server).size()); 744 EXPECT_EQ(0u, impl_.GetAlternativeServiceInfos(https_server).size());
738 745
739 // Set Alt-Svc list for |https_server|. 746 // Set Alt-Svc list for |https_server|.
740 impl_.SetAlternativeServices(https_server, alternative_service_info_vector); 747 impl_.SetAlternativeServices(https_server, alternative_service_info_vector);
741 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size()); 748 EXPECT_EQ(2u, impl_.GetAlternativeServiceInfos(https_server).size());
742 EXPECT_EQ(2u, impl_.GetAlternativeServices(http_server).size()); 749 EXPECT_EQ(2u, impl_.GetAlternativeServiceInfos(http_server).size());
743 750
744 // Clear Alt-Svc list for |http_server|. 751 // Clear Alt-Svc list for |http_server|.
745 impl_.SetAlternativeServices(http_server, AlternativeServiceInfoVector()); 752 impl_.SetAlternativeServices(http_server, AlternativeServiceInfoVector());
746 753
747 EXPECT_EQ(0u, impl_.GetAlternativeServices(http_server).size()); 754 EXPECT_EQ(0u, impl_.GetAlternativeServiceInfos(http_server).size());
748 EXPECT_EQ(2u, impl_.GetAlternativeServices(https_server).size()); 755 EXPECT_EQ(2u, impl_.GetAlternativeServiceInfos(https_server).size());
749 } 756 }
750 757
751 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) { 758 TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
752 AlternativeServiceInfoVector alternative_service_info_vector; 759 AlternativeServiceInfoVector alternative_service_info_vector;
753 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443); 760 const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
754 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 761 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
755 alternative_service_info_vector.push_back( 762 alternative_service_info_vector.push_back(
756 AlternativeServiceInfo(alternative_service1, expiration)); 763 AlternativeServiceInfo(alternative_service1, expiration));
757 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234); 764 const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
758 alternative_service_info_vector.push_back( 765 alternative_service_info_vector.push_back(
(...skipping 15 matching lines...) Expand all
774 // A broken alternative service in the mapping carries meaningful information, 781 // A broken alternative service in the mapping carries meaningful information,
775 // therefore it should not be ignored by SetAlternativeService(). In 782 // therefore it should not be ignored by SetAlternativeService(). In
776 // particular, an alternative service mapped to an origin shadows alternative 783 // particular, an alternative service mapped to an origin shadows alternative
777 // services of canonical hosts. 784 // services of canonical hosts.
778 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) { 785 TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {
779 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 786 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
780 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 787 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
781 AlternativeService canonical_alternative_service(kProtoQUIC, 788 AlternativeService canonical_alternative_service(kProtoQUIC,
782 "bar.c.youtube.com", 1234); 789 "bar.c.youtube.com", 1234);
783 SetAlternativeService(canonical_server, canonical_alternative_service); 790 SetAlternativeService(canonical_server, canonical_alternative_service);
784 AlternativeServiceVector alternative_service_vector = 791 AlternativeServiceInfoVector alternative_service_info_vector =
785 impl_.GetAlternativeServices(test_server); 792 impl_.GetAlternativeServiceInfos(test_server);
786 ASSERT_EQ(1u, alternative_service_vector.size()); 793 ASSERT_EQ(1u, alternative_service_info_vector.size());
787 EXPECT_EQ(canonical_alternative_service, alternative_service_vector[0]); 794 EXPECT_EQ(canonical_alternative_service,
795 alternative_service_info_vector[0].alternative_service);
788 796
789 const AlternativeService broken_alternative_service(kProtoHTTP2, "foo", 443); 797 const AlternativeService broken_alternative_service(kProtoHTTP2, "foo", 443);
790 impl_.MarkAlternativeServiceBroken(broken_alternative_service); 798 impl_.MarkAlternativeServiceBroken(broken_alternative_service);
791 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); 799 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
792 800
793 SetAlternativeService(test_server, broken_alternative_service); 801 SetAlternativeService(test_server, broken_alternative_service);
794 alternative_service_vector = impl_.GetAlternativeServices(test_server); 802 alternative_service_info_vector =
795 ASSERT_EQ(1u, alternative_service_vector.size()); 803 impl_.GetAlternativeServiceInfos(test_server);
796 EXPECT_EQ(broken_alternative_service, alternative_service_vector[0]); 804 ASSERT_EQ(1u, alternative_service_info_vector.size());
805 EXPECT_EQ(broken_alternative_service,
806 alternative_service_info_vector[0].alternative_service);
797 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service)); 807 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(broken_alternative_service));
798 } 808 }
799 809
800 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { 810 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {
801 url::SchemeHostPort test_server("http", "foo", 80); 811 url::SchemeHostPort test_server("http", "foo", 80);
802 const AlternativeService alternative_service(kProtoHTTP2, "foo", 443); 812 const AlternativeService alternative_service(kProtoHTTP2, "foo", 443);
803 SetAlternativeService(test_server, alternative_service); 813 SetAlternativeService(test_server, alternative_service);
804 impl_.MarkAlternativeServiceBroken(alternative_service); 814 impl_.MarkAlternativeServiceBroken(alternative_service);
805 ASSERT_TRUE(HasAlternativeService(test_server)); 815 ASSERT_TRUE(HasAlternativeService(test_server));
806 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service)); 816 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 850 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
841 alternative_service_info_vector.push_back( 851 alternative_service_info_vector.push_back(
842 AlternativeServiceInfo(canonical_alternative_service1, expiration)); 852 AlternativeServiceInfo(canonical_alternative_service1, expiration));
843 const AlternativeService canonical_alternative_service2(kProtoHTTP2, "", 443); 853 const AlternativeService canonical_alternative_service2(kProtoHTTP2, "", 443);
844 alternative_service_info_vector.push_back( 854 alternative_service_info_vector.push_back(
845 AlternativeServiceInfo(canonical_alternative_service2, expiration)); 855 AlternativeServiceInfo(canonical_alternative_service2, expiration));
846 impl_.SetAlternativeServices(canonical_server, 856 impl_.SetAlternativeServices(canonical_server,
847 alternative_service_info_vector); 857 alternative_service_info_vector);
848 858
849 // Since |test_server| does not have an alternative service itself, 859 // Since |test_server| does not have an alternative service itself,
850 // GetAlternativeServices should return those of |canonical_server|. 860 // GetAlternativeServiceInfos should return those of |canonical_server|.
851 AlternativeServiceVector alternative_service_vector = 861 AlternativeServiceInfoVector alternative_service_info_vector2 =
852 impl_.GetAlternativeServices(test_server); 862 impl_.GetAlternativeServiceInfos(test_server);
853 ASSERT_EQ(2u, alternative_service_vector.size()); 863 ASSERT_EQ(2u, alternative_service_info_vector2.size());
854 EXPECT_EQ(canonical_alternative_service1, alternative_service_vector[0]); 864 EXPECT_EQ(canonical_alternative_service1,
865 alternative_service_info_vector2[0].alternative_service);
855 866
856 // Since |canonical_alternative_service2| has an empty host, 867 // Since |canonical_alternative_service2| has an empty host,
857 // GetAlternativeServices should substitute the hostname of its |origin| 868 // GetAlternativeServiceInfos should substitute the hostname of its |origin|
858 // argument. 869 // argument.
859 EXPECT_EQ(test_server.host(), alternative_service_vector[1].host); 870 EXPECT_EQ(test_server.host(),
871 alternative_service_info_vector2[1].alternative_service.host);
860 EXPECT_EQ(canonical_alternative_service2.protocol, 872 EXPECT_EQ(canonical_alternative_service2.protocol,
861 alternative_service_vector[1].protocol); 873 alternative_service_info_vector2[1].alternative_service.protocol);
862 EXPECT_EQ(canonical_alternative_service2.port, 874 EXPECT_EQ(canonical_alternative_service2.port,
863 alternative_service_vector[1].port); 875 alternative_service_info_vector2[1].alternative_service.port);
864 876
865 // Verify the canonical suffix. 877 // Verify the canonical suffix.
866 EXPECT_EQ(".c.youtube.com", *impl_.GetCanonicalSuffix(test_server.host())); 878 EXPECT_EQ(".c.youtube.com", *impl_.GetCanonicalSuffix(test_server.host()));
867 EXPECT_EQ(".c.youtube.com", 879 EXPECT_EQ(".c.youtube.com",
868 *impl_.GetCanonicalSuffix(canonical_server.host())); 880 *impl_.GetCanonicalSuffix(canonical_server.host()));
869 } 881 }
870 882
871 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { 883 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {
872 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 884 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
873 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 885 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
(...skipping 17 matching lines...) Expand all
891 EXPECT_FALSE(HasAlternativeService(test_server)); 903 EXPECT_FALSE(HasAlternativeService(test_server));
892 } 904 }
893 905
894 // Adding an alternative service for a new host overrides canonical host. 906 // Adding an alternative service for a new host overrides canonical host.
895 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) { 907 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) {
896 url::SchemeHostPort foo_server("https", "foo.c.youtube.com", 443); 908 url::SchemeHostPort foo_server("https", "foo.c.youtube.com", 443);
897 url::SchemeHostPort bar_server("https", "bar.c.youtube.com", 443); 909 url::SchemeHostPort bar_server("https", "bar.c.youtube.com", 443);
898 AlternativeService bar_alternative_service(kProtoQUIC, "bar.c.youtube.com", 910 AlternativeService bar_alternative_service(kProtoQUIC, "bar.c.youtube.com",
899 1234); 911 1234);
900 SetAlternativeService(bar_server, bar_alternative_service); 912 SetAlternativeService(bar_server, bar_alternative_service);
901 AlternativeServiceVector alternative_service_vector = 913 AlternativeServiceInfoVector alternative_service_info_vector =
902 impl_.GetAlternativeServices(foo_server); 914 impl_.GetAlternativeServiceInfos(foo_server);
903 ASSERT_EQ(1u, alternative_service_vector.size()); 915 ASSERT_EQ(1u, alternative_service_info_vector.size());
904 EXPECT_EQ(bar_alternative_service, alternative_service_vector[0]); 916 EXPECT_EQ(bar_alternative_service,
917 alternative_service_info_vector[0].alternative_service);
905 918
906 url::SchemeHostPort qux_server("https", "qux.c.youtube.com", 443); 919 url::SchemeHostPort qux_server("https", "qux.c.youtube.com", 443);
907 AlternativeService qux_alternative_service(kProtoQUIC, "qux.c.youtube.com", 920 AlternativeService qux_alternative_service(kProtoQUIC, "qux.c.youtube.com",
908 443); 921 443);
909 SetAlternativeService(qux_server, qux_alternative_service); 922 SetAlternativeService(qux_server, qux_alternative_service);
910 alternative_service_vector = impl_.GetAlternativeServices(foo_server); 923 alternative_service_info_vector =
911 ASSERT_EQ(1u, alternative_service_vector.size()); 924 impl_.GetAlternativeServiceInfos(foo_server);
912 EXPECT_EQ(qux_alternative_service, alternative_service_vector[0]); 925 ASSERT_EQ(1u, alternative_service_info_vector.size());
926 EXPECT_EQ(qux_alternative_service,
927 alternative_service_info_vector[0].alternative_service);
913 } 928 }
914 929
915 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) { 930 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) {
916 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443); 931 url::SchemeHostPort test_server("https", "foo.c.youtube.com", 443);
917 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443); 932 url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
918 AlternativeService canonical_alternative_service(kProtoQUIC, 933 AlternativeService canonical_alternative_service(kProtoQUIC,
919 "bar.c.youtube.com", 1234); 934 "bar.c.youtube.com", 1234);
920 935
921 SetAlternativeService(canonical_server, canonical_alternative_service); 936 SetAlternativeService(canonical_server, canonical_alternative_service);
922 impl_.Clear(); 937 impl_.Clear();
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1239 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1225 1240
1226 impl_.Clear(); 1241 impl_.Clear();
1227 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1242 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1228 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1243 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1229 } 1244 }
1230 1245
1231 } // namespace 1246 } // namespace
1232 1247
1233 } // namespace net 1248 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698