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

Side by Side Diff: chrome/browser/net/predictor_browsertest.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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
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 <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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 observer()->set_task_runner(task_runner_); 538 observer()->set_task_runner(task_runner_);
539 StartInterceptingCrossSiteOnUI(); 539 StartInterceptingCrossSiteOnUI();
540 } 540 }
541 541
542 static void StartInterceptingHostWithCreateJobCallback( 542 static void StartInterceptingHostWithCreateJobCallback(
543 const GURL& url, 543 const GURL& url,
544 const MatchingPortRequestInterceptor::CreateJobCallback& callback) { 544 const MatchingPortRequestInterceptor::CreateJobCallback& callback) {
545 DCHECK_CURRENTLY_ON(BrowserThread::IO); 545 DCHECK_CURRENTLY_ON(BrowserThread::IO);
546 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( 546 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor(
547 url.scheme(), url.host(), 547 url.scheme(), url.host(),
548 base::WrapUnique(new MatchingPortRequestInterceptor( 548 base::MakeUnique<MatchingPortRequestInterceptor>(url.EffectiveIntPort(),
549 url.EffectiveIntPort(), callback))); 549 callback));
550 } 550 }
551 551
552 static void StopInterceptingHost(const GURL& url) { 552 static void StopInterceptingHost(const GURL& url) {
553 DCHECK_CURRENTLY_ON(BrowserThread::IO); 553 DCHECK_CURRENTLY_ON(BrowserThread::IO);
554 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(url.scheme(), 554 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(url.scheme(),
555 url.host()); 555 url.host());
556 } 556 }
557 557
558 // Intercepts all requests to the specified host and returns a response with 558 // Intercepts all requests to the specified host and returns a response with
559 // an empty body. Needed to prevent requests from actually going to the test 559 // an empty body. Needed to prevent requests from actually going to the test
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 // would preconnect 4 sockets if it were doing so based on learning. 999 // would preconnect 4 sockets if it were doing so based on learning.
1000 EXPECT_EQ(navigation_preconnects, observer()->CrossSitePreconnected()); 1000 EXPECT_EQ(navigation_preconnects, observer()->CrossSitePreconnected());
1001 } 1001 }
1002 1002
1003 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PredictBasedOnSubframeRedirect) { 1003 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PredictBasedOnSubframeRedirect) {
1004 // A test server is needed here because data url navigations with redirect 1004 // A test server is needed here because data url navigations with redirect
1005 // interceptors don't interact well with the ResourceTiming API. 1005 // interceptors don't interact well with the ResourceTiming API.
1006 // TODO(csharrison): Possibly this is a bug in either net or Blink, and it 1006 // TODO(csharrison): Possibly this is a bug in either net or Blink, and it
1007 // might be worthwhile to investigate. 1007 // might be worthwhile to investigate.
1008 std::unique_ptr<net::EmbeddedTestServer> redirector = 1008 std::unique_ptr<net::EmbeddedTestServer> redirector =
1009 base::WrapUnique(new net::EmbeddedTestServer()); 1009 base::MakeUnique<net::EmbeddedTestServer>();
1010 ASSERT_TRUE(redirector->Start()); 1010 ASSERT_TRUE(redirector->Start());
1011 1011
1012 NavigateToCrossSiteHtmlUrl(1 /* num_cors */, "" /* file_suffix */); 1012 NavigateToCrossSiteHtmlUrl(1 /* num_cors */, "" /* file_suffix */);
1013 EXPECT_EQ(1, observer()->CrossSiteLearned()); 1013 EXPECT_EQ(1, observer()->CrossSiteLearned());
1014 EXPECT_EQ(0u, cross_site_connection_listener_->GetAcceptedSocketCount()); 1014 EXPECT_EQ(0u, cross_site_connection_listener_->GetAcceptedSocketCount());
1015 1015
1016 redirector->RegisterRequestHandler( 1016 redirector->RegisterRequestHandler(
1017 base::Bind(&RedirectForPathHandler, "/", 1017 base::Bind(&RedirectForPathHandler, "/",
1018 embedded_test_server()->GetURL("/title1.html"))); 1018 embedded_test_server()->GetURL("/title1.html")));
1019 1019
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 // Second navigation to content with an img. 1561 // Second navigation to content with an img.
1562 std::string img_content = 1562 std::string img_content =
1563 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; 1563 "<img src=\"" + preconnect_url.spec() + "test.gif\">";
1564 NavigateToDataURLWithContent(img_content); 1564 NavigateToDataURLWithContent(img_content);
1565 connection_listener_->WaitUntilFirstConnectionRead(); 1565 connection_listener_->WaitUntilFirstConnectionRead();
1566 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); 1566 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount());
1567 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); 1567 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
1568 } 1568 }
1569 1569
1570 } // namespace chrome_browser_net 1570 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/errorpage_browsertest.cc ('k') | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698