Commit b96cc904 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Prerender: Replace "swap" to "activate" for unification of terminology

Before this CL, we called the navigation to prerendered contents "swap".
However, we decided to consistently call it "activate". This CL replaces
existing usage.

Bug: 1132746
Change-Id: I4c45b177ceccda4732023ea529e8aeb3a3b0c16b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494201Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820152}
parent 575c8952
......@@ -59,21 +59,22 @@ void PrerenderHost::StartPrerendering() {
}
void PrerenderHost::DidFinishNavigation(NavigationHandle* navigation_handle) {
// The prerendered contents are considered ready for swapping when it reaches
// DidFinishNavigation.
DCHECK(!is_ready_to_swap_);
is_ready_to_swap_ = true;
// The prerendered contents are considered ready for activation when it
// reaches DidFinishNavigation.
DCHECK(!is_ready_for_activation_);
is_ready_for_activation_ = true;
// Stop observing the events about the prerendered contents.
Observe(nullptr);
}
bool PrerenderHost::SwapToPrerenderedContents(
bool PrerenderHost::ActivatePrerenderedContents(
RenderFrameHostImpl& current_render_frame_host) {
// TODO(https://crbug.com/1132746): We may have to cancel prerendering if
// SwapToPrerenderedContents() is called before DidFinishNavigation() because
// it is likely that the prerenderered contents are never used after that.
if (!is_ready_to_swap_ || !prerendered_contents_)
// ActivatePrerenderedContents() is called before DidFinishNavigation()
// because it is likely that the prerenderered contents are never used after
// that.
if (!is_ready_for_activation_ || !prerendered_contents_)
return false;
auto* current_web_contents =
......@@ -81,10 +82,10 @@ bool PrerenderHost::SwapToPrerenderedContents(
if (!current_web_contents)
return false;
// Swap to the prerendered contents.
// Activate the prerendered contents.
WebContentsDelegate* delegate = current_web_contents->GetDelegate();
DCHECK(delegate);
// Tentatively use Portal's activation function that swaps WebContents.
// Tentatively use Portal's activation function.
// TODO(https://crbug.com/1132746): Replace this with the MPArch.
delegate->ActivatePortalWebContents(current_web_contents,
std::move(prerendered_contents_));
......
......@@ -21,7 +21,7 @@ class WebContents;
// Prerender2:
// PrerenderHost creates a new WebContents and starts prerendering with that.
// Then navigation code is expected to find this host from PrerenderHostRegistry
// and swap in the prerendered WebContents upon navigation. This is created per
// and activate the prerendered WebContents upon navigation. This is created per
// request from a renderer process via PrerenderProcessor or will directly be
// created for browser-initiated prerendering (this code path is not implemented
// yet). This is owned by PrerenderHostRegistry.
......@@ -45,10 +45,10 @@ class CONTENT_EXPORT PrerenderHost final : public WebContentsObserver {
// WebContentsObserver implementation:
void DidFinishNavigation(NavigationHandle* navigation_handle) override;
// Swaps `current_render_frame_host`'s contents with the prerendered
// contents. Returns false when swap didn't occur for some reason (e.g., the
// prerendered contents are not ready to swap).
bool SwapToPrerenderedContents(
// Activates the prerendered contents. Returns false when activation didn't
// occur for some reason (e.g., the prerendered contents are not ready for
// activation yet).
bool ActivatePrerenderedContents(
RenderFrameHostImpl& current_render_frame_host);
private:
......@@ -61,8 +61,8 @@ class CONTENT_EXPORT PrerenderHost final : public WebContentsObserver {
// use the new MPArch mechanism.
std::unique_ptr<WebContents> prerendered_contents_;
// Indicates if `prerendered_contents_` is ready to swap.
bool is_ready_to_swap_ = false;
// Indicates if `prerendered_contents_` is ready for activation.
bool is_ready_for_activation_ = false;
};
} // namespace content
......
......@@ -16,7 +16,7 @@ class PrerenderHost;
// Prerender2:
// PrerenderHostRegistry manages running prerender hosts and provides the host
// to navigation code for swapping to prerendered contents. This is created and
// to navigation code for activating prerendered contents. This is created and
// owned by StoragePartitionImpl.
//
// TODO(https://crbug.com/1132746): Once the Prerender2 is migrated to the
......
......@@ -72,8 +72,7 @@ TEST_F(PrerenderHostTest, StartPrerendering) {
// the prerendered contents.
prerender_host->DidFinishNavigation(nullptr);
// Swap to the prerendered contents.
EXPECT_TRUE(prerender_host->SwapToPrerenderedContents(*render_frame_host));
EXPECT_TRUE(prerender_host->ActivatePrerenderedContents(*render_frame_host));
}
} // namespace
......
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