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

Unified Diff: chrome/browser/prerender/prerender_test_utils.h

Issue 2452313002: Revert of [NoStatePrefetch] Kill renderer after preload scanning (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_test_utils.h
diff --git a/chrome/browser/prerender/prerender_test_utils.h b/chrome/browser/prerender/prerender_test_utils.h
index d7f4af8de292a2d9585e96eb596dcaeefde913c7..9a31279dc5eec25a2ccaf7f0e9e0b0816b636006 100644
--- a/chrome/browser/prerender/prerender_test_utils.h
+++ b/chrome/browser/prerender/prerender_test_utils.h
@@ -144,13 +144,11 @@
bool should_be_shown_;
// If true, |expected_final_status_| and other shutdown checks are skipped.
bool skip_final_checks_;
-
- DISALLOW_COPY_AND_ASSIGN(TestPrerenderContents);
};
// A handle to a TestPrerenderContents whose lifetime is under the caller's
// control. A PrerenderContents may be destroyed at any point. This allows
-// tracking the FinalStatus.
+// tracking the final status, etc.
class TestPrerender : public PrerenderContents::Observer,
public base::SupportsWeakPtr<TestPrerender> {
public:
@@ -159,7 +157,6 @@
TestPrerenderContents* contents() const { return contents_; }
int number_of_loads() const { return number_of_loads_; }
- FinalStatus GetFinalStatus() const;
void WaitForCreate();
void WaitForStart();
@@ -182,7 +179,6 @@
private:
TestPrerenderContents* contents_;
- FinalStatus final_status_;
int number_of_loads_;
int expected_number_of_loads_;
@@ -227,8 +223,6 @@
private:
DestructionWaiter* waiter_;
-
- DISALLOW_COPY_AND_ASSIGN(DestructionMarker);
};
// To be called by a DestructionMarker.
@@ -238,8 +232,6 @@
FinalStatus expected_final_status_;
bool saw_correct_status_;
std::unique_ptr<DestructionMarker> marker_;
-
- DISALLOW_COPY_AND_ASSIGN(DestructionWaiter);
};
// PrerenderContentsFactory that uses TestPrerenderContents.
@@ -272,8 +264,6 @@
};
std::deque<ExpectedContents> expected_contents_queue_;
-
- DISALLOW_COPY_AND_ASSIGN(TestPrerenderContentsFactory);
};
class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
@@ -304,6 +294,21 @@
TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const;
+ std::unique_ptr<TestPrerender> PrerenderTestURL(
+ const std::string& html_file,
+ FinalStatus expected_final_status,
+ int expected_number_of_loads);
+
+ std::unique_ptr<TestPrerender> PrerenderTestURL(
+ const GURL& url,
+ FinalStatus expected_final_status,
+ int expected_number_of_loads);
+
+ std::vector<std::unique_ptr<TestPrerender>> PrerenderTestURL(
+ const std::string& html_file,
+ const std::vector<FinalStatus>& expected_final_status_queue,
+ int expected_number_of_loads);
+
// Set up an HTTPS server.
void UseHttpsSrcServer();
@@ -338,23 +343,26 @@
base::string16 MatchTaskManagerPrerender(const char* page_title);
protected:
- // For each FinalStatus in |expected_final_status_queue| creates a prerender
- // that is going to verify the correctness of its FinalStatus upon
- // destruction. Waits for creation of the first PrerenderContents.
+ // To be called from PrerenderTestUrlImpl. Sets up the appropraite prerenders,
+ // checking for the expected final status, navigates to the loader url, and
+ // waits for the load.
std::vector<std::unique_ptr<TestPrerender>> NavigateWithPrerenders(
const GURL& loader_url,
- const std::vector<FinalStatus>& expected_final_status_queue);
-
- // Creates the URL that instructs the test server to substitute the text
- // |replacement_variable| in the contents of the file pointed to by
- // |loader_path| with |url_to_prerender|. Also appends the |loader_query| to
- // the URL.
- GURL ServeLoaderURL(const std::string& loader_path,
- const std::string& replacement_variable,
- const GURL& url_to_prerender,
- const std::string& loader_query);
-
- private:
+ const std::vector<FinalStatus>& expected_final_status_queue,
+ int expected_number_of_loads);
+
+ private:
+ // Implement load of a url for a prerender test. prerender_url should be
+ // loaded, and we should expect to see one prerenderer created, and exit, for
+ // each entry in expected_final_status_queue, and seeing
+ // expected_number_of_loads. Specific tests can provide additional
+ // verification. Note this should be called by one of the convenience wrappers
+ // defined above.
+ virtual std::vector<std::unique_ptr<TestPrerender>> PrerenderTestURLImpl(
+ const GURL& prerender_url,
+ const std::vector<FinalStatus>& expected_final_status_queue,
+ int expected_number_of_loads) = 0;
+
std::unique_ptr<ExternalProtocolHandler::Delegate>
external_protocol_handler_delegate_;
std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory>
@@ -364,8 +372,6 @@
bool autostart_test_server_;
base::HistogramTester histogram_tester_;
std::unique_ptr<net::EmbeddedTestServer> https_src_server_;
-
- DISALLOW_COPY_AND_ASSIGN(PrerenderInProcessBrowserTest);
};
// Makes |url| respond to requests with the contents of |file|, counting the
« no previous file with comments | « chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc ('k') | chrome/browser/prerender/prerender_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698