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

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

Issue 2455653005: Revert "Revert of [NoStatePrefetch] Kill renderer after preload scanning (patchset #12 id:240001 of… (Closed)
Patch Set: rebased 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 9a31279dc5eec25a2ccaf7f0e9e0b0816b636006..d7f4af8de292a2d9585e96eb596dcaeefde913c7 100644
--- a/chrome/browser/prerender/prerender_test_utils.h
+++ b/chrome/browser/prerender/prerender_test_utils.h
@@ -144,11 +144,13 @@ class TestPrerenderContents : public PrerenderContents {
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 final status, etc.
+// tracking the FinalStatus.
class TestPrerender : public PrerenderContents::Observer,
public base::SupportsWeakPtr<TestPrerender> {
public:
@@ -157,6 +159,7 @@ class TestPrerender : public PrerenderContents::Observer,
TestPrerenderContents* contents() const { return contents_; }
int number_of_loads() const { return number_of_loads_; }
+ FinalStatus GetFinalStatus() const;
void WaitForCreate();
void WaitForStart();
@@ -179,6 +182,7 @@ class TestPrerender : public PrerenderContents::Observer,
private:
TestPrerenderContents* contents_;
+ FinalStatus final_status_;
int number_of_loads_;
int expected_number_of_loads_;
@@ -223,6 +227,8 @@ class DestructionWaiter {
private:
DestructionWaiter* waiter_;
+
+ DISALLOW_COPY_AND_ASSIGN(DestructionMarker);
};
// To be called by a DestructionMarker.
@@ -232,6 +238,8 @@ class DestructionWaiter {
FinalStatus expected_final_status_;
bool saw_correct_status_;
std::unique_ptr<DestructionMarker> marker_;
+
+ DISALLOW_COPY_AND_ASSIGN(DestructionWaiter);
};
// PrerenderContentsFactory that uses TestPrerenderContents.
@@ -264,6 +272,8 @@ class TestPrerenderContentsFactory : public PrerenderContents::Factory {
};
std::deque<ExpectedContents> expected_contents_queue_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestPrerenderContentsFactory);
};
class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
@@ -294,21 +304,6 @@ class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
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();
@@ -343,26 +338,23 @@ class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
base::string16 MatchTaskManagerPrerender(const char* page_title);
protected:
- // 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.
+ // 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.
std::vector<std::unique_ptr<TestPrerender>> NavigateWithPrerenders(
const GURL& loader_url,
- const std::vector<FinalStatus>& expected_final_status_queue,
- int expected_number_of_loads);
+ const std::vector<FinalStatus>& expected_final_status_queue);
- 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;
+ // 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:
std::unique_ptr<ExternalProtocolHandler::Delegate>
external_protocol_handler_delegate_;
std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory>
@@ -372,6 +364,8 @@ class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
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