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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
7 #include <deque> 6 #include <deque>
7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 TestPrerenderContentsFactory() {} 668 TestPrerenderContentsFactory() {}
669 669
670 ~TestPrerenderContentsFactory() override { 670 ~TestPrerenderContentsFactory() override {
671 EXPECT_TRUE(expected_contents_queue_.empty()); 671 EXPECT_TRUE(expected_contents_queue_.empty());
672 } 672 }
673 673
674 scoped_ptr<TestPrerender> ExpectPrerenderContents(FinalStatus final_status) { 674 scoped_ptr<TestPrerender> ExpectPrerenderContents(FinalStatus final_status) {
675 scoped_ptr<TestPrerender> handle(new TestPrerender()); 675 scoped_ptr<TestPrerender> handle(new TestPrerender());
676 expected_contents_queue_.push_back( 676 expected_contents_queue_.push_back(
677 ExpectedContents(final_status, handle->AsWeakPtr())); 677 ExpectedContents(final_status, handle->AsWeakPtr()));
678 return handle.Pass(); 678 return handle;
679 } 679 }
680 680
681 PrerenderContents* CreatePrerenderContents( 681 PrerenderContents* CreatePrerenderContents(
682 PrerenderManager* prerender_manager, 682 PrerenderManager* prerender_manager,
683 Profile* profile, 683 Profile* profile,
684 const GURL& url, 684 const GURL& url,
685 const content::Referrer& referrer, 685 const content::Referrer& referrer,
686 Origin origin) override { 686 Origin origin) override {
687 ExpectedContents expected; 687 ExpectedContents expected;
688 if (!expected_contents_queue_.empty()) { 688 if (!expected_contents_queue_.empty()) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 897
898 // Makes |url| never respond on the first load, and then with the contents of 898 // Makes |url| never respond on the first load, and then with the contents of
899 // |file| afterwards. When the first load has been scheduled, runs |callback| on 899 // |file| afterwards. When the first load has been scheduled, runs |callback| on
900 // the UI thread. 900 // the UI thread.
901 void CreateHangingFirstRequestInterceptorOnIO( 901 void CreateHangingFirstRequestInterceptorOnIO(
902 const GURL& url, const base::FilePath& file, base::Closure callback) { 902 const GURL& url, const base::FilePath& file, base::Closure callback) {
903 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 903 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
904 scoped_ptr<net::URLRequestInterceptor> never_respond_handler( 904 scoped_ptr<net::URLRequestInterceptor> never_respond_handler(
905 new HangingFirstRequestInterceptor(file, callback)); 905 new HangingFirstRequestInterceptor(file, callback));
906 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( 906 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
907 url, never_respond_handler.Pass()); 907 url, std::move(never_respond_handler));
908 } 908 }
909 909
910 // Wrapper over URLRequestMockHTTPJob that exposes extra callbacks. 910 // Wrapper over URLRequestMockHTTPJob that exposes extra callbacks.
911 class MockHTTPJob : public net::URLRequestMockHTTPJob { 911 class MockHTTPJob : public net::URLRequestMockHTTPJob {
912 public: 912 public:
913 MockHTTPJob(net::URLRequest* request, 913 MockHTTPJob(net::URLRequest* request,
914 net::NetworkDelegate* delegate, 914 net::NetworkDelegate* delegate,
915 const base::FilePath& file) 915 const base::FilePath& file)
916 : net::URLRequestMockHTTPJob( 916 : net::URLRequestMockHTTPJob(
917 request, 917 request,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 // Makes |url| respond to requests with the contents of |file|, counting the 1003 // Makes |url| respond to requests with the contents of |file|, counting the
1004 // number that start in |counter|. 1004 // number that start in |counter|.
1005 void CreateCountingInterceptorOnIO( 1005 void CreateCountingInterceptorOnIO(
1006 const GURL& url, 1006 const GURL& url,
1007 const base::FilePath& file, 1007 const base::FilePath& file,
1008 const base::WeakPtr<RequestCounter>& counter) { 1008 const base::WeakPtr<RequestCounter>& counter) {
1009 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1009 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1010 scoped_ptr<net::URLRequestInterceptor> request_interceptor( 1010 scoped_ptr<net::URLRequestInterceptor> request_interceptor(
1011 new CountingInterceptor(file, counter)); 1011 new CountingInterceptor(file, counter));
1012 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( 1012 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
1013 url, request_interceptor.Pass()); 1013 url, std::move(request_interceptor));
1014 } 1014 }
1015 1015
1016 // Makes |url| respond to requests with the contents of |file|. 1016 // Makes |url| respond to requests with the contents of |file|.
1017 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file) { 1017 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file) {
1018 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1018 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1019 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( 1019 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
1020 url, 1020 url,
1021 net::URLRequestMockHTTPJob::CreateInterceptorForSingleFile( 1021 net::URLRequestMockHTTPJob::CreateInterceptorForSingleFile(
1022 file, BrowserThread::GetBlockingPool())); 1022 file, BrowserThread::GetBlockingPool()));
1023 } 1023 }
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 1633
1634 // Test that the referring page received the right start and load events. 1634 // Test that the referring page received the right start and load events.
1635 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); 1635 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0));
1636 if (check_load_events_) { 1636 if (check_load_events_) {
1637 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); 1637 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads());
1638 EXPECT_EQ(expected_number_of_loads, 1638 EXPECT_EQ(expected_number_of_loads,
1639 GetPrerenderLoadEventCountForLinkNumber(0)); 1639 GetPrerenderLoadEventCountForLinkNumber(0));
1640 } 1640 }
1641 EXPECT_FALSE(HadPrerenderEventErrors()); 1641 EXPECT_FALSE(HadPrerenderEventErrors());
1642 1642
1643 return prerenders.Pass(); 1643 return prerenders;
1644 } 1644 }
1645 1645
1646 void NavigateToURLImpl(const content::OpenURLParams& params, 1646 void NavigateToURLImpl(const content::OpenURLParams& params,
1647 bool expect_swap_to_succeed) const { 1647 bool expect_swap_to_succeed) const {
1648 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager()); 1648 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager());
1649 // Make sure in navigating we have a URL to use in the PrerenderManager. 1649 // Make sure in navigating we have a URL to use in the PrerenderManager.
1650 ASSERT_NE(static_cast<PrerenderContents*>(NULL), GetPrerenderContents()); 1650 ASSERT_NE(static_cast<PrerenderContents*>(NULL), GetPrerenderContents());
1651 1651
1652 WebContents* web_contents = GetPrerenderContents()->prerender_contents(); 1652 WebContents* web_contents = GetPrerenderContents()->prerender_contents();
1653 1653
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
3890 const GURL& url, 3890 const GURL& url,
3891 FinalStatus expected_final_status) { 3891 FinalStatus expected_final_status) {
3892 scoped_ptr<TestPrerender> prerender = 3892 scoped_ptr<TestPrerender> prerender =
3893 ExpectPrerender(expected_final_status); 3893 ExpectPrerender(expected_final_status);
3894 WebContents* web_contents = GetActiveWebContents(); 3894 WebContents* web_contents = GetActiveWebContents();
3895 GetAutocompleteActionPredictor()->StartPrerendering( 3895 GetAutocompleteActionPredictor()->StartPrerendering(
3896 url, 3896 url,
3897 web_contents->GetController().GetDefaultSessionStorageNamespace(), 3897 web_contents->GetController().GetDefaultSessionStorageNamespace(),
3898 gfx::Size(50, 50)); 3898 gfx::Size(50, 50));
3899 prerender->WaitForStart(); 3899 prerender->WaitForStart();
3900 return prerender.Pass(); 3900 return prerender;
3901 } 3901 }
3902 }; 3902 };
3903 3903
3904 // Checks that closing the omnibox popup cancels an omnibox prerender. 3904 // Checks that closing the omnibox popup cancels an omnibox prerender.
3905 // http://crbug.com/395152 3905 // http://crbug.com/395152
3906 IN_PROC_BROWSER_TEST_F(PrerenderOmniboxBrowserTest, 3906 IN_PROC_BROWSER_TEST_F(PrerenderOmniboxBrowserTest,
3907 DISABLED_PrerenderOmniboxCancel) { 3907 DISABLED_PrerenderOmniboxCancel) {
3908 // Fake an omnibox prerender. 3908 // Fake an omnibox prerender.
3909 scoped_ptr<TestPrerender> prerender = StartOmniboxPrerender( 3909 scoped_ptr<TestPrerender> prerender = StartOmniboxPrerender(
3910 embedded_test_server()->GetURL("/empty.html"), FINAL_STATUS_CANCELLED); 3910 embedded_test_server()->GetURL("/empty.html"), FINAL_STATUS_CANCELLED);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4046 4046
4047 NavigateToDestURL(); 4047 NavigateToDestURL();
4048 EXPECT_EQ(1U, task_manager.tasks().size()); 4048 EXPECT_EQ(1U, task_manager.tasks().size());
4049 } 4049 }
4050 4050
4051 } // namespace 4051 } // namespace
4052 4052
4053 #endif // defined(ENABLE_TASK_MANAGER) 4053 #endif // defined(ENABLE_TASK_MANAGER)
4054 4054
4055 } // namespace prerender 4055 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698