0

Convert FrameMsg_SwapIn to Mojo

This CL migrates the legacy FrameMsg_SwapIn IPC message
to the new Mojo message in FrameNavigationControl interface.

In RenderFrameImpl class, the existing OnSwapIn() is renamed
to SwapIn() which implements the Mojo message, then SwapIn()
is renamed to SwapInInternal() to avoid duplicating the
implementation of the SwapIn of FrameNavigationControl
interface.

Bug: 1064342
Change-Id: If131fa3d91c73a7a71c609ca282ef437f16482a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2167737
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763840}
This commit is contained in:
Gyuyoung Kim
2020-04-29 16:00:26 +00:00
committed by Commit Bot
parent fe21d55195
commit 11aad0b604
7 changed files with 33 additions and 28 deletions

@ -2140,6 +2140,10 @@ void RenderFrameHostImpl::SetRenderFrameCreated(bool created) {
document_associated_data_.ClearAllUserData();
}
void RenderFrameHostImpl::SwapIn() {
GetNavigationControl()->SwapIn();
}
void RenderFrameHostImpl::Init() {
ResumeBlockedRequestsForFrame();
if (!waiting_for_init_)

@ -1092,6 +1092,10 @@ class CONTENT_EXPORT RenderFrameHostImpl
const base::string16& target_origin,
blink::TransferableMessage message);
// Requests to swap the current frame into the frame tree, replacing the
// RenderFrameProxy it is associated with.
void SwapIn();
// Manual RTTI to ensure safe downcasts in tests.
virtual bool IsTestRenderFrameHost() const;

@ -949,10 +949,8 @@ RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation(
// done earlier to keep browser and renderer state in sync. This is
// important to do before CommitPending(), which destroys the
// corresponding proxy. See https://crbug.com/487872.
if (GetRenderFrameProxyHost(dest_site_instance.get())) {
navigation_rfh->Send(
new FrameMsg_SwapIn(navigation_rfh->GetRoutingID()));
}
if (GetRenderFrameProxyHost(dest_site_instance.get()))
navigation_rfh->SwapIn();
CommitPending(std::move(speculative_render_frame_host_), nullptr,
request->require_coop_browsing_instance_swap());
}
@ -3104,8 +3102,7 @@ void RenderFrameHostManager::CreateNewFrameForInnerDelegateAttachIfNecessary() {
}
// Swap in the speculative frame. It will later be replaced when
// WebContents::AttachToOuterWebContentsFrame is called.
speculative_render_frame_host_->Send(
new FrameMsg_SwapIn(speculative_render_frame_host_->GetRoutingID()));
speculative_render_frame_host_->SwapIn();
CommitPending(std::move(speculative_render_frame_host_), nullptr,
false /* clear_proxies_on_commit */);
NotifyPrepareForInnerDelegateAttachComplete(true /* success */);

@ -244,6 +244,15 @@ interface FrameNavigationControl {
pending_associated_receiver<blink.mojom.PortalClient> portal_client,
blink.mojom.TransferableMessage data)
=> (blink.mojom.PortalActivateResult result);
// Requests that a provisional RenderFrame swap itself into the frame tree,
// replacing the RenderFrameProxy that it is associated with. This is used
// with remote-to-local frame navigations when the RenderFrameProxy
// corresponds to a non-live (crashed) frame. In that case, the browser
// process will send this message as part of an early commit to stop showing
// the sad iframe without waiting for the provisional RenderFrame's navigation
// to commit.
SwapIn();
};
// Implemented by the frame (e.g. renderer processes).

@ -496,14 +496,6 @@ IPC_MESSAGE_ROUTED1(FrameMsg_UpdateOpener, int /* opener_routing_id */)
// commit, activation and frame swap of the current DOM tree in blink.
IPC_MESSAGE_ROUTED1(FrameMsg_VisualStateRequest, uint64_t /* id */)
// Requests that a provisional RenderFrame swap itself into the frame tree,
// replacing the RenderFrameProxy that it is associated with. This is used
// with remote-to-local frame navigations when the RenderFrameProxy corresponds
// to a non-live (crashed) frame. In that case, the browser process will send
// this message as part of an early commit to stop showing the sad iframe
// without waiting for the provisional RenderFrame's navigation to commit.
IPC_MESSAGE_ROUTED0(FrameMsg_SwapIn)
// Instructs the frame to stop the load in progress, if any.
IPC_MESSAGE_ROUTED0(FrameMsg_Stop)

@ -2175,7 +2175,6 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
IPC_MESSAGE_HANDLER(UnfreezableFrameMsg_Unload, OnUnload)
IPC_MESSAGE_HANDLER(FrameMsg_SwapIn, OnSwapIn)
IPC_MESSAGE_HANDLER(FrameMsg_Stop, OnStop)
IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed)
IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction,
@ -2341,10 +2340,6 @@ void RenderFrameImpl::OnUnload(
task_runner->PostTask(FROM_HERE, std::move(send_unload_ack));
}
void RenderFrameImpl::OnSwapIn() {
SwapIn();
}
void RenderFrameImpl::OnDeleteFrame(FrameDeleteIntention intent) {
// The main frame (when not provisional) is owned by the renderer's frame tree
// via WebViewImpl. When a provisional main frame is swapped in, the ownership
@ -2609,6 +2604,10 @@ void RenderFrameImpl::OnPortalActivated(
std::move(callback));
}
void RenderFrameImpl::SwapIn() {
SwapInInternal();
}
void RenderFrameImpl::ForwardMessageFromHost(
blink::TransferableMessage message,
const url::Origin& source_origin,
@ -4207,7 +4206,7 @@ void RenderFrameImpl::DidCommitNavigation(
// If this is a provisional frame associated with a proxy (i.e., a frame
// created for a remote-to-local navigation), swap it into the frame tree
// now.
if (!SwapIn())
if (!SwapInInternal())
return;
}
@ -5444,7 +5443,7 @@ blink::mojom::CommitResult RenderFrameImpl::PrepareForHistoryNavigationCommit(
return blink::mojom::CommitResult::Ok;
}
bool RenderFrameImpl::SwapIn() {
bool RenderFrameImpl::SwapInInternal() {
CHECK_NE(previous_routing_id_, MSG_ROUTING_NONE);
CHECK(!in_frame_tree_);

@ -621,6 +621,7 @@ class CONTENT_EXPORT RenderFrameImpl
mojo::PendingAssociatedReceiver<blink::mojom::PortalClient> portal_client,
blink::TransferableMessage data,
OnPortalActivatedCallback callback) override;
void SwapIn() override;
// mojom::FullscreenVideoElementHandler implementation:
void RequestFullscreenVideoElement() override;
@ -1003,12 +1004,12 @@ class CONTENT_EXPORT RenderFrameImpl
void RemoveObserver(RenderFrameObserver* observer);
// Swaps the current frame into the frame tree, replacing the
// RenderFrameProxy it is associated with. Return value indicates whether
// the swap operation succeeded. This should only be used for provisional
// frames associated with a proxy, while the proxy is still in the frame
// tree. If the associated proxy has been detached before this is called,
// this returns false and aborts the swap.
bool SwapIn();
// RenderFrameProxy it is associated with. Return value indicates whether
// the swap operation succeeded. This should only be used for provisional
// frames associated with a proxy, while the proxy is still in the frame tree.
// If the associated proxy has been detached before this is called, this
// returns false and aborts the swap.
bool SwapInInternal();
// Returns the RenderWidget associated with the main frame.
// TODO(ajwong): This method should go away when cross-frame property setting
@ -1022,7 +1023,6 @@ class CONTENT_EXPORT RenderFrameImpl
//
// The documentation for these functions should be in
// content/common/*_messages.h for the message that the function is handling.
void OnSwapIn();
void OnUnload(int proxy_routing_id,
bool is_loading,
const FrameReplicationState& replicated_frame_state);