Chromium Code Reviews| 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 "chrome/browser/net/predictor.h" | 5 #include "chrome/browser/net/predictor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 predictor.DeserializeReferrers(*referral_list.get()); | 544 predictor.DeserializeReferrers(*referral_list.get()); |
| 545 | 545 |
| 546 predictor.PreconnectUrlAndSubresources(kHttpUrl, GURL()); | 546 predictor.PreconnectUrlAndSubresources(kHttpUrl, GURL()); |
| 547 ASSERT_EQ(2u, observer.preconnected_urls_.size()); | 547 ASSERT_EQ(2u, observer.preconnected_urls_.size()); |
| 548 EXPECT_EQ(kHttpsUrl, observer.preconnected_urls_[0]); | 548 EXPECT_EQ(kHttpsUrl, observer.preconnected_urls_[0]); |
| 549 EXPECT_EQ(kSubresourceUrl, observer.preconnected_urls_[1]); | 549 EXPECT_EQ(kSubresourceUrl, observer.preconnected_urls_[1]); |
| 550 | 550 |
| 551 predictor.Shutdown(); | 551 predictor.Shutdown(); |
| 552 } | 552 } |
| 553 | 553 |
| 554 TEST_F(PredictorTest, HSTSRedirectLearnedSubresource) { | |
| 555 const GURL kHttpUrl("http://example.com"); | |
| 556 const GURL kHttpsUrl("https://example.com"); | |
| 557 const GURL kSubresourceUrl("https://images.example.com"); | |
| 558 | |
| 559 const base::Time expiry = | |
| 560 base::Time::Now() + base::TimeDelta::FromSeconds(1000); | |
| 561 net::TransportSecurityState state; | |
| 562 state.AddHSTS(kHttpUrl.host(), expiry, false); | |
| 563 | |
| 564 SimplePredictor predictor(true, true); | |
| 565 TestPredictorObserver observer; | |
| 566 predictor.SetObserver(&observer); | |
| 567 predictor.SetTransportSecurityState(&state); | |
| 568 | |
| 569 predictor.LearnFromNavigation(kHttpUrl, kSubresourceUrl); | |
|
mmenke
2016/06/01 18:19:44
We'd also call predictor.LearnFromNavigation(kHttp
Charlie Harrison
2016/06/01 19:50:34
Yeah we'd learn it. Do you think that fits in the
| |
| 570 | |
| 571 predictor.PreconnectUrlAndSubresources(kHttpUrl, GURL()); | |
| 572 ASSERT_EQ(2u, observer.preconnected_urls_.size()); | |
| 573 EXPECT_EQ(kHttpsUrl, observer.preconnected_urls_[0]); | |
| 574 EXPECT_EQ(kSubresourceUrl, observer.preconnected_urls_[1]); | |
| 575 | |
| 576 predictor.Shutdown(); | |
| 577 } | |
| 578 | |
| 554 TEST_F(PredictorTest, NoProxyService) { | 579 TEST_F(PredictorTest, NoProxyService) { |
| 555 // Don't actually try to resolve names. | 580 // Don't actually try to resolve names. |
| 556 Predictor::set_max_parallel_resolves(0); | 581 Predictor::set_max_parallel_resolves(0); |
| 557 | 582 |
| 558 Predictor testing_master(true, true); | 583 Predictor testing_master(true, true); |
| 559 | 584 |
| 560 GURL goog("http://www.google.com:80"); | 585 GURL goog("http://www.google.com:80"); |
| 561 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); | 586 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); |
| 562 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); | 587 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); |
| 563 | 588 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); | 644 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); |
| 620 | 645 |
| 621 // Proxy may not be in use (the PAC script has not yet been evaluated), so the | 646 // Proxy may not be in use (the PAC script has not yet been evaluated), so the |
| 622 // name has been registered for pre-resolve. | 647 // name has been registered for pre-resolve. |
| 623 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); | 648 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); |
| 624 | 649 |
| 625 testing_master.Shutdown(); | 650 testing_master.Shutdown(); |
| 626 } | 651 } |
| 627 | 652 |
| 628 } // namespace chrome_browser_net | 653 } // namespace chrome_browser_net |
| OLD | NEW |