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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 rule_based_resolver_proc_->AddRuleWithLatency("gmail.com", "127.0.0.1", 63); | 507 rule_based_resolver_proc_->AddRuleWithLatency("gmail.com", "127.0.0.1", 63); |
508 rule_based_resolver_proc_->AddSimulatedFailure("*.notfound"); | 508 rule_based_resolver_proc_->AddSimulatedFailure("*.notfound"); |
509 rule_based_resolver_proc_->AddRuleWithLatency("delay.google.com", | 509 rule_based_resolver_proc_->AddRuleWithLatency("delay.google.com", |
510 "127.0.0.1", 1000 * 60); | 510 "127.0.0.1", 1000 * 60); |
511 } | 511 } |
512 | 512 |
513 protected: | 513 protected: |
514 void SetUpInProcessBrowserTestFixture() override { | 514 void SetUpInProcessBrowserTestFixture() override { |
515 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc( | 515 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc( |
516 rule_based_resolver_proc_.get())); | 516 rule_based_resolver_proc_.get())); |
517 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | |
518 } | 517 } |
519 | 518 |
520 void SetUpCommandLine(base::CommandLine* command_line) override { | 519 void SetUpCommandLine(base::CommandLine* command_line) override { |
521 command_line->AppendSwitch( | 520 command_line->AppendSwitch( |
522 switches::kEnableExperimentalWebPlatformFeatures); | 521 switches::kEnableExperimentalWebPlatformFeatures); |
523 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 522 command_line->AppendSwitchASCII(switches::kEnableFeatures, |
524 "PreconnectMore"); | 523 "PreconnectMore"); |
525 } | 524 } |
526 | 525 |
527 void SetUpOnMainThread() override { | 526 void SetUpOnMainThread() override { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // text/html. | 597 // text/html. |
599 void NavigateToDataURLWithContent(const std::string& content) { | 598 void NavigateToDataURLWithContent(const std::string& content) { |
600 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 599 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
601 std::string encoded_content; | 600 std::string encoded_content; |
602 base::Base64Encode(content, &encoded_content); | 601 base::Base64Encode(content, &encoded_content); |
603 std::string data_uri_content = "data:text/html;base64," + encoded_content; | 602 std::string data_uri_content = "data:text/html;base64," + encoded_content; |
604 ui_test_utils::NavigateToURL(browser(), GURL(data_uri_content)); | 603 ui_test_utils::NavigateToURL(browser(), GURL(data_uri_content)); |
605 } | 604 } |
606 | 605 |
607 void TearDownInProcessBrowserTestFixture() override { | 606 void TearDownInProcessBrowserTestFixture() override { |
608 InProcessBrowserTest::TearDownInProcessBrowserTestFixture(); | |
609 scoped_host_resolver_proc_.reset(); | 607 scoped_host_resolver_proc_.reset(); |
610 } | 608 } |
611 | 609 |
612 void LearnAboutInitialNavigation(const GURL& url) { | 610 void LearnAboutInitialNavigation(const GURL& url) { |
613 BrowserThread::PostTask( | 611 BrowserThread::PostTask( |
614 BrowserThread::IO, FROM_HERE, | 612 BrowserThread::IO, FROM_HERE, |
615 base::BindOnce(&Predictor::LearnAboutInitialNavigation, | 613 base::BindOnce(&Predictor::LearnAboutInitialNavigation, |
616 base::Unretained(predictor()), url)); | 614 base::Unretained(predictor()), url)); |
617 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 615 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
618 } | 616 } |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 // Second navigation to content with an img. | 1584 // Second navigation to content with an img. |
1587 std::string img_content = | 1585 std::string img_content = |
1588 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1586 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
1589 NavigateToDataURLWithContent(img_content); | 1587 NavigateToDataURLWithContent(img_content); |
1590 connection_listener_->WaitUntilFirstConnectionRead(); | 1588 connection_listener_->WaitUntilFirstConnectionRead(); |
1591 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1589 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
1592 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1590 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
1593 } | 1591 } |
1594 | 1592 |
1595 } // namespace chrome_browser_net | 1593 } // namespace chrome_browser_net |
OLD | NEW |