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 <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 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc( | 457 scoped_host_resolver_proc_.reset(new net::ScopedDefaultHostResolverProc( |
| 458 host_resolution_request_recorder_.get())); | 458 host_resolution_request_recorder_.get())); |
| 459 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 459 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void SetUpCommandLine(base::CommandLine* command_line) override { | 462 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 463 command_line->AppendSwitch( | 463 command_line->AppendSwitch( |
| 464 switches::kEnableExperimentalWebPlatformFeatures); | 464 switches::kEnableExperimentalWebPlatformFeatures); |
| 465 command_line->AppendSwitchASCII( | 465 command_line->AppendSwitchASCII( |
| 466 switches::kEnableBlinkFeatures, kBlinkPreconnectFeature); | 466 switches::kEnableBlinkFeatures, kBlinkPreconnectFeature); |
| 467 command_line->AppendSwitchASCII(switches::kEnableFeatures, | |
| 468 "PreconnectMore"); | |
| 467 } | 469 } |
| 468 | 470 |
| 469 void SetUpOnMainThread() override { | 471 void SetUpOnMainThread() override { |
| 470 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 472 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 471 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 473 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 472 cross_site_test_server_->ServeFilesFromSourceDirectory("chrome/test/data/"); | 474 cross_site_test_server_->ServeFilesFromSourceDirectory("chrome/test/data/"); |
| 473 | 475 |
| 474 connection_listener_.reset(new ConnectionListener()); | 476 connection_listener_.reset(new ConnectionListener()); |
| 475 cross_site_connection_listener_.reset(new ConnectionListener()); | 477 cross_site_connection_listener_.reset(new ConnectionListener()); |
| 476 embedded_test_server()->SetConnectionListener(connection_listener_.get()); | 478 embedded_test_server()->SetConnectionListener(connection_listener_.get()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 return cross_site_test_server_.get(); | 589 return cross_site_test_server_.get(); |
| 588 } | 590 } |
| 589 | 591 |
| 590 Predictor* predictor() { return browser()->profile()->GetNetworkPredictor(); } | 592 Predictor* predictor() { return browser()->profile()->GetNetworkPredictor(); } |
| 591 | 593 |
| 592 void InstallPredictorObserver(const GURL& source_host, | 594 void InstallPredictorObserver(const GURL& source_host, |
| 593 const GURL& cross_site_host) { | 595 const GURL& cross_site_host) { |
| 594 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 596 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 595 observer_.reset( | 597 observer_.reset( |
| 596 new CrossSitePredictorObserver(source_host, cross_site_host)); | 598 new CrossSitePredictorObserver(source_host, cross_site_host)); |
| 597 BrowserThread::PostTask( | 599 base::RunLoop run_loop; |
|
mmenke
2016/05/16 19:10:07
These shouldn't be needed - anything that does any
Charlie Harrison
2016/05/16 19:13:39
Ack. Thanks for the clarification. I'll keep it fo
| |
| 600 BrowserThread::PostTaskAndReply( | |
| 598 BrowserThread::IO, FROM_HERE, | 601 BrowserThread::IO, FROM_HERE, |
| 599 base::Bind(&PredictorBrowserTest::InstallPredictorObserverOnIOThread, | 602 base::Bind(&PredictorBrowserTest::InstallPredictorObserverOnIOThread, |
| 600 base::Unretained(this), base::Unretained(predictor()))); | 603 base::Unretained(this), base::Unretained(predictor())), |
| 604 run_loop.QuitClosure()); | |
| 605 run_loop.Run(); | |
| 601 } | 606 } |
| 602 | 607 |
| 603 void InstallPredictorObserverOnIOThread( | 608 void InstallPredictorObserverOnIOThread( |
| 604 chrome_browser_net::Predictor* predictor) { | 609 chrome_browser_net::Predictor* predictor) { |
| 605 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 610 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 606 predictor->SetObserver(observer_.get()); | 611 predictor->SetObserver(observer_.get()); |
| 607 } | 612 } |
| 608 | 613 |
| 609 // Note: For many of the tests to get to a "clean slate" mid run, they must | 614 // Note: For many of the tests to get to a "clean slate" mid run, they must |
| 610 // flush sockets on both the client and server. | 615 // flush sockets on both the client and server. |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 // Second navigation to content with an img. | 1247 // Second navigation to content with an img. |
| 1243 std::string img_content = | 1248 std::string img_content = |
| 1244 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1249 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
| 1245 NavigateToDataURLWithContent(img_content); | 1250 NavigateToDataURLWithContent(img_content); |
| 1246 connection_listener_->WaitUntilFirstConnectionRead(); | 1251 connection_listener_->WaitUntilFirstConnectionRead(); |
| 1247 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1252 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
| 1248 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1253 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
| 1249 } | 1254 } |
| 1250 | 1255 |
| 1251 } // namespace chrome_browser_net | 1256 } // namespace chrome_browser_net |
| OLD | NEW |