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