Commit 5eb7fc6d authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Prerender] Part 1: Delete old style prerender code.

This is to be submitted once all changes for Bug 898955 have landed.

Bug: 1106294
Change-Id: I1beb9f425c4f7774831a155be38483ae9b9aed4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302010
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792073}
parent f3ec10b3
...@@ -374,14 +374,6 @@ TabAndroid::TabLoadStatus TabAndroid::LoadUrl( ...@@ -374,14 +374,6 @@ TabAndroid::TabLoadStatus TabAndroid::LoadUrl(
if (gurl.is_empty()) if (gurl.is_empty())
return PAGE_LOAD_FAILED; return PAGE_LOAD_FAILED;
// If the page was prerendered, use it.
// Note in incognito mode, we don't have a PrerenderManager.
bool loaded;
if (prerender::PrerenderManager::MaybeUsePrerenderedPage(
GetProfile(), web_contents(), gurl, &loaded)) {
return loaded ? FULL_PRERENDERED_PAGE_LOAD : PARTIAL_PRERENDERED_PAGE_LOAD;
}
GURL fixed_url( GURL fixed_url(
url_formatter::FixupURL(gurl.possibly_invalid_spec(), std::string())); url_formatter::FixupURL(gurl.possibly_invalid_spec(), std::string()));
if (!fixed_url.is_valid()) if (!fixed_url.is_valid())
......
...@@ -384,17 +384,6 @@ WebContents* TabWebContentsDelegateAndroid::OpenURLFromTab( ...@@ -384,17 +384,6 @@ WebContents* TabWebContentsDelegateAndroid::OpenURLFromTab(
} }
if (disposition == WindowOpenDisposition::CURRENT_TAB) { if (disposition == WindowOpenDisposition::CURRENT_TAB) {
// Only prerender for a current-tab navigation to avoid session storage
// namespace issues.
prerender::PrerenderManager::Params prerender_params(
popup_delegate->nav_params(), source);
prerender::PrerenderManager* prerender_manager =
prerender::PrerenderManagerFactory::GetForBrowserContext(profile);
if (prerender_manager && prerender_manager->MaybeUsePrerenderedPage(
params.url, &prerender_params)) {
return prerender_params.replaced_contents;
}
// Ask the parent to handle in-place opening. // Ask the parent to handle in-place opening.
return WebContentsDelegateAndroid::OpenURLFromTab(source, params); return WebContentsDelegateAndroid::OpenURLFromTab(source, params);
} }
......
...@@ -135,8 +135,7 @@ PrerenderContents::PrerenderContents( ...@@ -135,8 +135,7 @@ PrerenderContents::PrerenderContents(
const content::Referrer& referrer, const content::Referrer& referrer,
const base::Optional<url::Origin>& initiator_origin, const base::Optional<url::Origin>& initiator_origin,
Origin origin) Origin origin)
: prerender_mode_( : prerender_mode_(prerender::mojom::PrerenderMode::kNoPrerender),
prerender::mojom::PrerenderMode::kDeprecatedFullPrerender),
prerendering_has_started_(false), prerendering_has_started_(false),
prerender_manager_(prerender_manager), prerender_manager_(prerender_manager),
prerender_url_(url), prerender_url_(url),
......
...@@ -36,8 +36,6 @@ class ListValue; ...@@ -36,8 +36,6 @@ class ListValue;
class TickClock; class TickClock;
} // namespace base } // namespace base
struct NavigateParams;
namespace chrome_browser_net { namespace chrome_browser_net {
enum class NetworkPredictionStatus; enum class NetworkPredictionStatus;
} }
...@@ -76,9 +74,6 @@ class PrerenderManager : public content::RenderProcessHostObserver, ...@@ -76,9 +74,6 @@ class PrerenderManager : public content::RenderProcessHostObserver,
public KeyedService { public KeyedService {
public: public:
enum PrerenderManagerMode { enum PrerenderManagerMode {
// Deprecated: Enables all types of prerendering for any origin.
DEPRECATED_PRERENDER_MODE_ENABLED,
// For each request to prerender performs a NoStatePrefetch for the same URL // For each request to prerender performs a NoStatePrefetch for the same URL
// instead. // instead.
PRERENDER_MODE_NOSTATE_PREFETCH, PRERENDER_MODE_NOSTATE_PREFETCH,
...@@ -96,22 +91,6 @@ class PrerenderManager : public content::RenderProcessHostObserver, ...@@ -96,22 +91,6 @@ class PrerenderManager : public content::RenderProcessHostObserver,
CLEAR_MAX = 0x1 << 2 CLEAR_MAX = 0x1 << 2
}; };
// If |url| matches a valid prerendered page in one of the contents,
// try to swap it and merge browsing histories.
//
// Returns true if a prerendered page is swapped in. When this happens, the
// PrerenderManager has already swapped out |contents_being_navigated| with
// |replaced_contents| in the WebContents container [e.g. TabStripModel on
// desktop]. |loaded| is set to true if the page finished loading.
//
// Returns false if nothing is swapped.
//
// |loaded| cannot be null.
static bool MaybeUsePrerenderedPage(Profile* profile,
content::WebContents* web_contents,
const GURL& url,
bool* loaded);
// Owned by a Profile object for the lifetime of the profile. // Owned by a Profile object for the lifetime of the profile.
explicit PrerenderManager(Profile* profile); explicit PrerenderManager(Profile* profile);
~PrerenderManager() override; ~PrerenderManager() override;
...@@ -183,36 +162,6 @@ class PrerenderManager : public content::RenderProcessHostObserver, ...@@ -183,36 +162,6 @@ class PrerenderManager : public content::RenderProcessHostObserver,
// Cancels all active prerenders. // Cancels all active prerenders.
void CancelAllPrerenders(); void CancelAllPrerenders();
// Wraps input and output parameters to MaybeUsePrerenderedPage.
struct Params {
Params(NavigateParams* params,
content::WebContents* contents_being_navigated);
Params(bool uses_post,
const std::string& extra_headers,
bool should_replace_current_entry,
content::WebContents* contents_being_navigated);
// Input parameters.
const bool uses_post;
const std::string extra_headers;
const bool should_replace_current_entry;
content::WebContents* const contents_being_navigated;
// Output parameters.
content::WebContents* replaced_contents = nullptr;
};
// If |url| matches a valid prerendered page and |params| are compatible, try
// to swap it and merge browsing histories.
//
// Returns true if a prerendered page is swapped in. When this happens, the
// PrerenderManager has already swapped out |contents_being_navigated| with
// |replaced_contents| in the WebContents container [e.g. TabStripModel on
// desktop].
//
// Returns false if nothing is swapped.
bool MaybeUsePrerenderedPage(const GURL& url, Params* params);
// Moves a PrerenderContents to the pending delete list from the list of // Moves a PrerenderContents to the pending delete list from the list of
// active prerenders when prerendering should be cancelled. // active prerenders when prerendering should be cancelled.
virtual void MoveEntryToPendingDelete(PrerenderContents* entry, virtual void MoveEntryToPendingDelete(PrerenderContents* entry,
......
...@@ -457,22 +457,6 @@ std::unique_ptr<content::WebContents> CreateTargetContents( ...@@ -457,22 +457,6 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
return target_contents; return target_contents;
} }
// If a prerendered page exists for |url|, then replace
// params.contents_being_navigated with it. When this occurs, the new page is
// stored in params.replaced_contents.
// This method updates the underlying storage mechanism as well. e.g. On
// Desktop, |contents_being_navigated| is replaced in the tabstrip by
// |replaced_contents|.
bool SwapInPrerender(const GURL& url,
prerender::PrerenderManager::Params* params) {
Profile* profile = Profile::FromBrowserContext(
params->contents_being_navigated->GetBrowserContext());
prerender::PrerenderManager* prerender_manager =
prerender::PrerenderManagerFactory::GetForBrowserContext(profile);
return prerender_manager &&
prerender_manager->MaybeUsePrerenderedPage(url, params);
}
} // namespace } // namespace
void Navigate(NavigateParams* params) { void Navigate(NavigateParams* params) {
...@@ -622,9 +606,6 @@ void Navigate(NavigateParams* params) { ...@@ -622,9 +606,6 @@ void Navigate(NavigateParams* params) {
params->transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR || params->transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR ||
!ui::PageTransitionIsWebTriggerable(params->transition); !ui::PageTransitionIsWebTriggerable(params->transition);
// Did we use a prerender?
bool swapped_in_prerender = false;
// If no target WebContents was specified (and we didn't seek and find a // If no target WebContents was specified (and we didn't seek and find a
// singleton), we need to construct one if we are supposed to target a new // singleton), we need to construct one if we are supposed to target a new
// tab. // tab.
...@@ -638,26 +619,15 @@ void Navigate(NavigateParams* params) { ...@@ -638,26 +619,15 @@ void Navigate(NavigateParams* params) {
// same as the source. // same as the source.
DCHECK(params->source_contents); DCHECK(params->source_contents);
contents_to_navigate_or_insert = params->source_contents; contents_to_navigate_or_insert = params->source_contents;
prerender::PrerenderManager::Params prerender_params(
params, params->source_contents);
// Prerender can only swap in CURRENT_TAB navigations; others have
// different sessionStorage namespaces.
swapped_in_prerender = SwapInPrerender(params->url, &prerender_params);
if (swapped_in_prerender)
contents_to_navigate_or_insert = prerender_params.replaced_contents;
} }
if (!swapped_in_prerender) { // Try to handle non-navigational URLs that popup dialogs and such, these
// Try to handle non-navigational URLs that popup dialogs and such, these // should not actually navigate.
// should not actually navigate. if (!HandleNonNavigationAboutURL(params->url)) {
if (!HandleNonNavigationAboutURL(params->url)) { // Perform the actual navigation, tracking whether it came from the
// Perform the actual navigation, tracking whether it came from the // renderer.
// renderer.
LoadURLInContents(contents_to_navigate_or_insert, params->url, params); LoadURLInContents(contents_to_navigate_or_insert, params->url, params);
}
} }
} else { } else {
// |contents_to_navigate_or_insert| was specified non-NULL, and so we assume // |contents_to_navigate_or_insert| was specified non-NULL, and so we assume
...@@ -674,9 +644,7 @@ void Navigate(NavigateParams* params) { ...@@ -674,9 +644,7 @@ void Navigate(NavigateParams* params) {
(params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER))
params->source_contents->Focus(); params->source_contents->Focus();
if (params->source_contents == contents_to_navigate_or_insert || if (params->source_contents == contents_to_navigate_or_insert) {
(swapped_in_prerender &&
params->disposition == WindowOpenDisposition::CURRENT_TAB)) {
// The navigation occurred in the source tab. // The navigation occurred in the source tab.
params->browser->UpdateUIForNavigationInTab( params->browser->UpdateUIForNavigationInTab(
contents_to_navigate_or_insert, params->transition, contents_to_navigate_or_insert, params->transition,
......
...@@ -8,9 +8,6 @@ enum PrerenderMode { ...@@ -8,9 +8,6 @@ enum PrerenderMode {
// Neither prefetch nor prerender. // Neither prefetch nor prerender.
kNoPrerender = 0, kNoPrerender = 0,
// Only used in tests. Can be removed after http://crbug.com/898955 is fixed.
kDeprecatedFullPrerender = 1,
// Prefetch some network resources to warm up the cache. // Prefetch some network resources to warm up the cache.
kPrefetchOnly = 2, kPrefetchOnly = 2,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment