Commit 83365b91 authored by danakj's avatar danakj Committed by Commit Bot

Remove redundant |swapped_out| from mojom::content::CreateViewParams

The field is true when there is no routing id for the main frame (ie
there is a proxy main frame), and false otherwise. So we can just use
that.

In the browser side it is actually a separate state, is_active_ on the
RenderViewHostImpl. However it is always set to true/false when the
main frame routing id is set as well. So we remove it and have
is_active() report if the main frame routing id is present instead.

R=alexmos@chromium.org
TBR=dcheng

Change-Id: I87c89f9d06ec99e769528e164e0ea0ed3d6fc6bc
Bug: 419087
Reviewed-on: https://chromium-review.googlesource.com/c/1336210
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608799}
parent fba08a8c
...@@ -2259,9 +2259,6 @@ void RenderFrameHostImpl::SwapOut( ...@@ -2259,9 +2259,6 @@ void RenderFrameHostImpl::SwapOut(
if (web_ui()) if (web_ui())
web_ui()->RenderFrameHostSwappingOut(); web_ui()->RenderFrameHostSwappingOut();
if (frame_tree_node_->IsMainFrame())
render_view_host_->SetIsActive(false);
} }
void RenderFrameHostImpl::OnBeforeUnloadACK( void RenderFrameHostImpl::OnBeforeUnloadACK(
......
...@@ -430,8 +430,7 @@ void RenderFrameHostManager::DiscardUnusedFrame( ...@@ -430,8 +430,7 @@ void RenderFrameHostManager::DiscardUnusedFrame(
// shortly, since |render_frame_host| is its last active frame and will be // shortly, since |render_frame_host| is its last active frame and will be
// deleted below. See https://crbug.com/627400. // deleted below. See https://crbug.com/627400.
if (frame_tree_node_->IsMainFrame()) { if (frame_tree_node_->IsMainFrame()) {
rvh->set_main_frame_routing_id(MSG_ROUTING_NONE); rvh->SetMainFrameRoutingId(MSG_ROUTING_NONE);
rvh->SetIsActive(false);
rvh->set_is_swapped_out(true); rvh->set_is_swapped_out(true);
} }
...@@ -2233,7 +2232,10 @@ void RenderFrameHostManager::CommitPending() { ...@@ -2233,7 +2232,10 @@ void RenderFrameHostManager::CommitPending() {
// to MSG_ROUTING_NONE. // to MSG_ROUTING_NONE.
if (is_main_frame) { if (is_main_frame) {
RenderViewHostImpl* rvh = render_frame_host_->render_view_host(); RenderViewHostImpl* rvh = render_frame_host_->render_view_host();
rvh->set_main_frame_routing_id(render_frame_host_->routing_id()); // Recall if the RenderViewHostImpl had a main frame routing id already. If
// not then it is transitioning from swapped out to active.
bool was_active = rvh->is_active();
rvh->SetMainFrameRoutingId(render_frame_host_->routing_id());
// If the RenderViewHost is transitioning from swapped out to active state, // If the RenderViewHost is transitioning from swapped out to active state,
// it was reused, so dispatch a RenderViewReady event. For example, this // it was reused, so dispatch a RenderViewReady event. For example, this
...@@ -2242,12 +2244,11 @@ void RenderFrameHostManager::CommitPending() { ...@@ -2242,12 +2244,11 @@ void RenderFrameHostManager::CommitPending() {
// //
// TODO(alexmos): Remove this and move RenderViewReady consumers to use // TODO(alexmos): Remove this and move RenderViewReady consumers to use
// the main frame's RenderFrameCreated instead. // the main frame's RenderFrameCreated instead.
if (!rvh->is_active()) if (!was_active)
rvh->PostRenderViewReady(); rvh->PostRenderViewReady();
rvh->SetIsActive(true);
rvh->set_is_swapped_out(false); rvh->set_is_swapped_out(false);
old_render_frame_host->render_view_host()->set_main_frame_routing_id( old_render_frame_host->render_view_host()->SetMainFrameRoutingId(
MSG_ROUTING_NONE); MSG_ROUTING_NONE);
} }
......
...@@ -214,7 +214,6 @@ RenderViewHostImpl::RenderViewHostImpl( ...@@ -214,7 +214,6 @@ RenderViewHostImpl::RenderViewHostImpl(
frames_ref_count_(0), frames_ref_count_(0),
delegate_(delegate), delegate_(delegate),
instance_(static_cast<SiteInstanceImpl*>(instance)), instance_(static_cast<SiteInstanceImpl*>(instance)),
is_active_(!swapped_out),
is_swapped_out_(swapped_out), is_swapped_out_(swapped_out),
routing_id_(routing_id), routing_id_(routing_id),
main_frame_routing_id_(main_frame_routing_id), main_frame_routing_id_(main_frame_routing_id),
...@@ -245,7 +244,7 @@ RenderViewHostImpl::RenderViewHostImpl( ...@@ -245,7 +244,7 @@ RenderViewHostImpl::RenderViewHostImpl(
// make their way to the new renderer once its restarted. // make their way to the new renderer once its restarted.
GetProcess()->EnableSendQueue(); GetProcess()->EnableSendQueue();
if (!is_active_) if (!is_active())
GetWidget()->UpdatePriority(); GetWidget()->UpdatePriority();
base::PostTaskWithTraits( base::PostTaskWithTraits(
...@@ -345,11 +344,10 @@ bool RenderViewHostImpl::CreateRenderView( ...@@ -345,11 +344,10 @@ bool RenderViewHostImpl::CreateRenderView(
delegate_->GetSessionStorageNamespace(instance_.get())->id(); delegate_->GetSessionStorageNamespace(instance_.get())->id();
// Ensure the RenderView sets its opener correctly. // Ensure the RenderView sets its opener correctly.
params->opener_frame_route_id = opener_frame_route_id; params->opener_frame_route_id = opener_frame_route_id;
params->swapped_out = !is_active_;
params->replicated_frame_state = replicated_frame_state; params->replicated_frame_state = replicated_frame_state;
params->proxy_routing_id = proxy_route_id; params->proxy_routing_id = proxy_route_id;
params->hidden = is_active_ ? GetWidget()->is_hidden() params->hidden = is_active() ? GetWidget()->is_hidden()
: GetWidget()->delegate()->IsHidden(); : GetWidget()->delegate()->IsHidden();
params->never_visible = delegate_->IsNeverVisible(); params->never_visible = delegate_->IsNeverVisible();
params->window_was_created_with_opener = window_was_created_with_opener; params->window_was_created_with_opener = window_was_created_with_opener;
if (main_rfh) { if (main_rfh) {
...@@ -380,10 +378,8 @@ bool RenderViewHostImpl::CreateRenderView( ...@@ -380,10 +378,8 @@ bool RenderViewHostImpl::CreateRenderView(
return true; return true;
} }
void RenderViewHostImpl::SetIsActive(bool is_active) { void RenderViewHostImpl::SetMainFrameRoutingId(int routing_id) {
if (is_active_ == is_active) main_frame_routing_id_ = routing_id;
return;
is_active_ = is_active;
GetWidget()->UpdatePriority(); GetWidget()->UpdatePriority();
} }
...@@ -900,11 +896,11 @@ bool RenderViewHostImpl::MayRenderWidgetForwardKeyboardEvent( ...@@ -900,11 +896,11 @@ bool RenderViewHostImpl::MayRenderWidgetForwardKeyboardEvent(
} }
bool RenderViewHostImpl::ShouldContributePriorityToProcess() { bool RenderViewHostImpl::ShouldContributePriorityToProcess() {
return is_active_; return is_active();
} }
void RenderViewHostImpl::RequestSetBounds(const gfx::Rect& bounds) { void RenderViewHostImpl::RequestSetBounds(const gfx::Rect& bounds) {
if (is_active_) if (is_active())
delegate_->RequestSetBounds(bounds); delegate_->RequestSetBounds(bounds);
} }
......
...@@ -138,8 +138,7 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, ...@@ -138,8 +138,7 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost,
// Tracks whether this RenderViewHost is in an active state (rather than // Tracks whether this RenderViewHost is in an active state (rather than
// pending swap out or swapped out), according to its main frame // pending swap out or swapped out), according to its main frame
// RenderFrameHost. // RenderFrameHost.
bool is_active() const { return is_active_; } bool is_active() const { return main_frame_routing_id_ != MSG_ROUTING_NONE; }
void SetIsActive(bool is_active);
// Tracks whether this RenderViewHost is swapped out, according to its main // Tracks whether this RenderViewHost is swapped out, according to its main
// frame RenderFrameHost. // frame RenderFrameHost.
...@@ -197,9 +196,9 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, ...@@ -197,9 +196,9 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost,
// GpuSwitchingObserver implementation. // GpuSwitchingObserver implementation.
void OnGpuSwitched() override; void OnGpuSwitched() override;
void set_main_frame_routing_id(int routing_id) { // Sets the routing id for the main frame. When set to MSG_ROUTING_NONE, the
main_frame_routing_id_ = routing_id; // view is not considered active.
} void SetMainFrameRoutingId(int routing_id);
// Increases the refcounting on this RVH. This is done by the FrameTree on // Increases the refcounting on this RVH. This is done by the FrameTree on
// creation of a RenderFrameHost or RenderFrameProxyHost. // creation of a RenderFrameHost or RenderFrameProxyHost.
...@@ -303,13 +302,8 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost, ...@@ -303,13 +302,8 @@ class CONTENT_EXPORT RenderViewHostImpl : public RenderViewHost,
// over time. // over time.
scoped_refptr<SiteInstanceImpl> instance_; scoped_refptr<SiteInstanceImpl> instance_;
// Tracks whether this RenderViewHost is in an active state. False if the
// main frame is pending swap out, pending deletion, or swapped out, because
// it is not visible to the user in any of these cases.
bool is_active_;
// Tracks whether the main frame RenderFrameHost is swapped out. Unlike // Tracks whether the main frame RenderFrameHost is swapped out. Unlike
// is_active_, this is false when the frame is pending swap out or deletion. // is_active(), this is false when the frame is pending swap out or deletion.
// TODO(creis): Remove this when we no longer filter IPCs after swap out. // TODO(creis): Remove this when we no longer filter IPCs after swap out.
// See https://crbug.com/745091. // See https://crbug.com/745091.
bool is_swapped_out_; bool is_swapped_out_;
......
...@@ -26,7 +26,8 @@ struct CreateViewParams { ...@@ -26,7 +26,8 @@ struct CreateViewParams {
int32 view_id = IPC.mojom.kRoutingIdNone; int32 view_id = IPC.mojom.kRoutingIdNone;
// The ID of the main frame hosted in the view, or None if creating a view to // The ID of the main frame hosted in the view, or None if creating a view to
// host a main frame proxy. // host a main frame proxy. If this is None, then |proxy_routing_id| should be
// set to something other than None.
int32 main_frame_routing_id = IPC.mojom.kRoutingIdNone; int32 main_frame_routing_id = IPC.mojom.kRoutingIdNone;
// The InterfaceProvider through which the main RenderFrame can access // The InterfaceProvider through which the main RenderFrame can access
...@@ -46,13 +47,9 @@ struct CreateViewParams { ...@@ -46,13 +47,9 @@ struct CreateViewParams {
// set one (MSG_ROUTING_NONE otherwise). // set one (MSG_ROUTING_NONE otherwise).
int32 opener_frame_route_id = IPC.mojom.kRoutingIdNone; int32 opener_frame_route_id = IPC.mojom.kRoutingIdNone;
// Whether the RenderView should initially be swapped out.
bool swapped_out;
// Carries replicated information, such as frame name and sandbox flags, for // Carries replicated information, such as frame name and sandbox flags, for
// this view's main frame, which will be a proxy in |swapped_out| // this view's main frame, which will be a proxy when |main_frame_routing_id|
// views when in --site-per-process mode, or a RenderFrame in all other // is None (due to site isolation), or a RenderFrame in all other cases.
// cases.
FrameReplicationState replicated_frame_state; FrameReplicationState replicated_frame_state;
// Used for devtools instrumentation and trace-ability. The token is // Used for devtools instrumentation and trace-ability. The token is
...@@ -64,7 +61,8 @@ struct CreateViewParams { ...@@ -64,7 +61,8 @@ struct CreateViewParams {
mojo_base.mojom.UnguessableToken devtools_main_frame_token; mojo_base.mojom.UnguessableToken devtools_main_frame_token;
// The ID of the proxy object for the main frame in this view. It is only // The ID of the proxy object for the main frame in this view. It is only
// used if |swapped_out| is true. // used if |main_frame_routing_id| is None, and exactly one of the two
// should be set to an id other than None at any time.
int32 proxy_routing_id = IPC.mojom.kRoutingIdNone; int32 proxy_routing_id = IPC.mojom.kRoutingIdNone;
// Whether the RenderView should initially be hidden. // Whether the RenderView should initially be hidden.
......
...@@ -349,7 +349,6 @@ void RenderViewTest::SetUp() { ...@@ -349,7 +349,6 @@ void RenderViewTest::SetUp() {
mojo::MakeRequest(&view_params->main_frame_interface_provider)); mojo::MakeRequest(&view_params->main_frame_interface_provider));
view_params->session_storage_namespace_id = view_params->session_storage_namespace_id =
blink::AllocateSessionStorageNamespaceId(); blink::AllocateSessionStorageNamespaceId();
view_params->swapped_out = false;
view_params->replicated_frame_state = FrameReplicationState(); view_params->replicated_frame_state = FrameReplicationState();
view_params->proxy_routing_id = MSG_ROUTING_NONE; view_params->proxy_routing_id = MSG_ROUTING_NONE;
view_params->hidden = false; view_params->hidden = false;
......
...@@ -431,14 +431,15 @@ cc::BrowserControlsState ContentToCc(BrowserControlsState state) { ...@@ -431,14 +431,15 @@ cc::BrowserControlsState ContentToCc(BrowserControlsState state) {
RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps,
const mojom::CreateViewParams& params) const mojom::CreateViewParams& params)
: RenderWidget(params.main_frame_widget_routing_id, : RenderWidget(
compositor_deps, params.main_frame_widget_routing_id,
WidgetType::kFrame, compositor_deps,
params.visual_properties.screen_info, WidgetType::kFrame,
params.visual_properties.display_mode, params.visual_properties.screen_info,
params.swapped_out, params.visual_properties.display_mode,
params.hidden, /*swapped_out=*/params.main_frame_routing_id == MSG_ROUTING_NONE,
params.never_visible), params.hidden,
params.never_visible),
routing_id_(params.view_id), routing_id_(params.view_id),
renderer_wide_named_frame_lookup_( renderer_wide_named_frame_lookup_(
params.renderer_wide_named_frame_lookup), params.renderer_wide_named_frame_lookup),
...@@ -537,7 +538,6 @@ void RenderViewImpl::Initialize( ...@@ -537,7 +538,6 @@ void RenderViewImpl::Initialize(
opener_frame, params->devtools_main_frame_token, opener_frame, params->devtools_main_frame_token,
params->replicated_frame_state, params->has_committed_real_load); params->replicated_frame_state, params->has_committed_real_load);
} else { } else {
CHECK(params->swapped_out);
RenderFrameProxy::CreateFrameProxy(params->proxy_routing_id, GetRoutingID(), RenderFrameProxy::CreateFrameProxy(params->proxy_routing_id, GetRoutingID(),
opener_frame, MSG_ROUTING_NONE, opener_frame, MSG_ROUTING_NONE,
params->replicated_frame_state, params->replicated_frame_state,
...@@ -1405,7 +1405,6 @@ WebView* RenderViewImpl::CreateView( ...@@ -1405,7 +1405,6 @@ WebView* RenderViewImpl::CreateView(
reply->cloned_session_storage_namespace_id; reply->cloned_session_storage_namespace_id;
DCHECK(!view_params->session_storage_namespace_id.empty()) DCHECK(!view_params->session_storage_namespace_id.empty())
<< "Session storage namespace must be populated."; << "Session storage namespace must be populated.";
view_params->swapped_out = false;
view_params->replicated_frame_state.frame_policy.sandbox_flags = view_params->replicated_frame_state.frame_policy.sandbox_flags =
sandbox_flags; sandbox_flags;
view_params->replicated_frame_state.name = frame_name_utf8; view_params->replicated_frame_state.name = frame_name_utf8;
......
...@@ -108,11 +108,12 @@ class CONTENT_EXPORT RenderViewImpl : private RenderWidget, ...@@ -108,11 +108,12 @@ class CONTENT_EXPORT RenderViewImpl : private RenderWidget,
public: public:
// Creates a new RenderView. Note that if the original opener has been closed, // Creates a new RenderView. Note that if the original opener has been closed,
// |params.window_was_created_with_opener| will be true and // |params.window_was_created_with_opener| will be true and
// |params.opener_frame_route_id| will be MSG_ROUTING_NONE. When // |params.opener_frame_route_id| will be MSG_ROUTING_NONE.
// |params.swapped_out| is true, |params.proxy_routing_id| is specified, so a // When |params.proxy_routing_id| instead of |params.main_frame_routing_id| is
// RenderFrameProxy can be created for this RenderView's main RenderFrame. The // specified, a RenderFrameProxy will be created for this RenderView's main
// opener should provide a non-null value for |show_callback| if it needs to // RenderFrame.
// send an additional IPC to finish making this view visible. // The opener should provide a non-null value for |show_callback| if it needs
// to send an additional IPC to finish making this view visible.
static RenderViewImpl* Create( static RenderViewImpl* Create(
CompositorDependencies* compositor_deps, CompositorDependencies* compositor_deps,
mojom::CreateViewParamsPtr params, mojom::CreateViewParamsPtr params,
......
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