Commit 6dcbc596 authored by danakj's avatar danakj Committed by Commit Bot

Rename "swapped out" and "for oopif" in RenderWidget.

is swapped out => is frozen
for oopif => for child local root frame

"Swapped out" was used in RenderWidget as the term comes from
RenderViewHost, and RenderFrame. The main frame can be swapped out -
meaning hosted in another process. RenderWidget is a separate layer
of the code however and we would like to delete them but we can't,
so they must enter this state of "inactivity". Thus, frozen. Then
we can more clearly separate frozen RenderWidgets from swapped out
frames and freeze/thaw RenderWidgets more appropriately.

"For oopif" is confusing as it seems to mean the RenderWidget is not
in the same frame tree as the main frame. However it can be when
there is an oopif in between the frame in question and the main
frame. Rename it to be more clear about when it is true.

R=ajwong@chromium.org, piman@chromium.org

Change-Id: I52e31acfbf098bfb993d1aea69b699b7bcbb8cbf
Bug: 905191, 419087
Reviewed-on: https://chromium-review.googlesource.com/c/1336218
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608808}
parent e330ef29
......@@ -28,9 +28,9 @@ namespace {
void RunClosureIfNotSwappedOut(base::WeakPtr<RenderWidget> render_widget,
base::OnceClosure closure) {
// Input messages must not be processed if the RenderWidget is in swapped out
// or closing state.
if (!render_widget || render_widget->is_swapped_out() ||
// Input messages must not be processed if the RenderWidget is in a frozen or
// closing state.
if (!render_widget || render_widget->is_frozen() ||
render_widget->is_closing()) {
return;
}
......
......@@ -409,7 +409,7 @@ void WidgetInputHandlerManager::HandleInputEvent(
const ui::WebScopedInputEvent& event,
const ui::LatencyInfo& latency,
mojom::WidgetInputHandler::DispatchEventCallback callback) {
if (!render_widget_ || render_widget_->is_swapped_out() ||
if (!render_widget_ || render_widget_->is_frozen() ||
render_widget_->is_closing()) {
if (callback) {
std::move(callback).Run(InputEventAckSource::MAIN_THREAD, latency,
......
......@@ -1496,13 +1496,13 @@ void RenderFrameImpl::CreateFrame(
render_widget = g_create_render_widget(
widget_params.routing_id, compositor_deps, WidgetType::kFrame,
screen_info_from_main_frame, blink::kWebDisplayModeUndefined,
/*swapped_out=*/false, widget_params.hidden,
/*is_frozen=*/false, widget_params.hidden,
/*never_visible=*/false);
} else {
render_widget = base::MakeRefCounted<RenderWidget>(
widget_params.routing_id, compositor_deps, WidgetType::kFrame,
screen_info_from_main_frame, blink::kWebDisplayModeUndefined,
/*swapped_out=*/false, widget_params.hidden,
/*is_frozen=*/false, widget_params.hidden,
/*never_visible=*/false);
}
......@@ -2235,9 +2235,9 @@ void RenderFrameImpl::OnSwapOut(
if (is_main_frame_) {
// The RenderWidget isn't actually closed here because we might need to use
// it again. It can't be destroyed and recreated later as it is part of
// the |render_view_|, which must be kept alive. So instead mark the widget
// as swapped out.
render_view_->GetWidget()->SetSwappedOut(true);
// the |render_view_|, which must be kept alive. So instead freeze the
// widget.
render_view_->GetWidget()->SetIsFrozen(true);
}
RenderViewImpl* render_view = render_view_;
......@@ -5916,8 +5916,11 @@ bool RenderFrameImpl::SwapIn() {
if (is_main_frame_) {
CHECK(!render_view_->main_render_frame_);
render_view_->main_render_frame_ = this;
if (render_view_->GetWidget()->is_swapped_out())
render_view_->GetWidget()->SetSwappedOut(false);
if (render_view_->GetWidget()->is_frozen()) {
// TODO(crbug.com/419087): The RenderWidget should be newly created here,
// then we won't have to do this.
render_view_->GetWidget()->SetIsFrozen(false);
}
render_view_->UpdateWebViewWithDeviceScaleFactor();
}
......
......@@ -142,12 +142,11 @@ RenderFrameProxy* RenderFrameProxy::CreateFrameProxy(
render_widget = render_view->GetWidget();
// If the RenderView is reused by this proxy after having been used for a
// pending RenderFrame that was discarded, its swapped out state needs to
// be updated, as the OnSwapOut flow which normally does this won't happen
// in that case. See https://crbug.com/653746 and
// https://crbug.com/651980.
if (!render_widget->is_swapped_out())
render_widget->SetSwappedOut(true);
// pending RenderFrame that was discarded, its widget needs to be frozen, as
// the OnSwapOut flow which normally does this won't happen in that case.
// See https://crbug.com/653746 and https://crbug.com/651980.
if (!render_widget->is_frozen())
render_widget->SetIsFrozen(true);
} else {
// Create a frame under an existing parent. The parent is always expected
// to be a RenderFrameProxy, because navigations initiated by local frames
......
......@@ -437,7 +437,7 @@ RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps,
WidgetType::kFrame,
params.visual_properties.screen_info,
params.visual_properties.display_mode,
/*swapped_out=*/params.main_frame_routing_id == MSG_ROUTING_NONE,
/*is_frozen=*/params.main_frame_routing_id == MSG_ROUTING_NONE,
params.hidden,
params.never_visible),
routing_id_(params.view_id),
......@@ -1460,7 +1460,7 @@ WebWidget* RenderViewImpl::CreatePopup(blink::WebLocalFrame* creator) {
widget_routing_id, view_render_widget->compositor_deps(),
WidgetType::kPopup, view_render_widget->screen_info(),
blink::kWebDisplayModeUndefined,
/*swapped_out=*/false,
/*is_frozen=*/false,
/*hidden=*/false,
/*never_visible=*/false, std::move(widget_channel_request));
......
......@@ -172,10 +172,10 @@ class CONTENT_EXPORT RenderViewImpl : private RenderWidget,
// Attaches a WebFrameWidget that will provide a WebFrameWidget interface to
// the WebView. Called as part of initialization or when the main frame
// RenderWidget is swapped in, to connect it to the new local main frame.
// RenderWidget is unfrozen, to connect it to the new local main frame.
void AttachWebFrameWidget(blink::WebFrameWidget* frame_widget);
// Detaches the current WebFrameWidget, disconnecting it from the main frame.
// Called when the RenderWidget is being swapped out, because the local main
// Called when the RenderWidget is being frozen, because the local main
// frame is going away.
void DetachWebFrameWidget();
......
......@@ -381,7 +381,7 @@ RenderWidget::RenderWidget(int32_t widget_routing_id,
WidgetType widget_type,
const ScreenInfo& screen_info,
blink::WebDisplayMode display_mode,
bool swapped_out,
bool is_frozen,
bool hidden,
bool never_visible,
mojom::WidgetRequest widget_request)
......@@ -397,7 +397,7 @@ RenderWidget::RenderWidget(int32_t widget_routing_id,
ime_event_guard_(nullptr),
closing_(false),
host_will_close_this_(false),
is_swapped_out_(swapped_out),
is_frozen_(is_frozen),
text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
text_input_flags_(0),
......@@ -413,7 +413,7 @@ RenderWidget::RenderWidget(int32_t widget_routing_id,
resizing_mode_selector_(new ResizingModeSelector()),
has_host_context_menu_location_(false),
has_focus_(false),
for_oopif_(false),
for_child_local_root_frame_(false),
#if defined(OS_MACOSX)
text_input_client_observer_(new TextInputClientObserver(this)),
#endif
......@@ -477,7 +477,7 @@ void RenderWidget::InitForPopup(ShowCallback show_callback,
void RenderWidget::InitForChildLocalRoot(
blink::WebFrameWidget* web_frame_widget) {
for_oopif_ = true;
for_child_local_root_frame_ = true;
// Init() increments the reference count on |this|, making it
// self-referencing.
Init(base::NullCallback(), web_frame_widget);
......@@ -626,10 +626,12 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
bool RenderWidget::Send(IPC::Message* message) {
// Don't send any messages after the browser has told us to close, and filter
// most outgoing messages while swapped out.
if ((is_swapped_out_ &&
!SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
closing_) {
// most outgoing messages when frozen.
if (closing_) {
delete message;
return false;
}
if (is_frozen_ && !SwappedOutMessages::CanSendWhileSwappedOut(message)) {
delete message;
return false;
}
......@@ -653,7 +655,7 @@ bool RenderWidget::ShouldHandleImeEvents() const {
// will be processed regardless of page focus. We should revisit this after
// page focus for OOPIFs has been fully resolved (https://crbug.com/689777).
return GetWebWidget() && GetWebWidget()->IsWebFrameWidget() &&
(has_focus_ || for_oopif_);
(has_focus_ || for_child_local_root_frame_);
}
void RenderWidget::OnClose() {
......@@ -678,7 +680,7 @@ void RenderWidget::OnClose() {
}
}
if (for_oopif_) {
if (for_child_local_root_frame_) {
// Widgets for frames may be created and closed at any time while the frame
// is alive. However, WebWidget must be closed synchronously because frame
// widgets and frames hold pointers to each other. The deferred call to
......@@ -806,7 +808,7 @@ void RenderWidget::OnWasShown(base::TimeTicks show_request_timestamp,
TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
// TODO(crbug.com/896836): CHECK to try track down why we make a frame sink
// for a RenderWidget without a main frame.
CHECK(!is_swapped_out_);
CHECK(!is_frozen_);
// During shutdown we can just ignore this message.
if (!GetWebWidget())
......@@ -859,7 +861,7 @@ void RenderWidget::HandleInputEvent(
const blink::WebCoalescedInputEvent& input_event,
const ui::LatencyInfo& latency_info,
HandledEventCallback callback) {
if (owner_delegate_ && is_swapped_out_) {
if (owner_delegate_ && is_frozen_) {
std::move(callback).Run(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, latency_info,
nullptr, base::nullopt);
return;
......@@ -972,8 +974,8 @@ void RenderWidget::RequestNewLayerTreeFrameSink(
// For widgets that are never visible, we don't start the compositor, so we
// never get a request for a cc::LayerTreeFrameSink.
DCHECK(!compositor_never_visible_);
// Swapped out RenderWidgets should not be doing any compositing.
DCHECK(!is_swapped_out_);
// Inactive RenderWidgets should not be doing any compositing.
DCHECK(!is_frozen_);
if (is_closing()) {
// In this case, we drop the request which means the compositor waits
......@@ -984,10 +986,10 @@ void RenderWidget::RequestNewLayerTreeFrameSink(
// TODO(crbug.com/896836): CHECK to try track down why we make a frame sink
// for a RenderWidget without a main frame. If there's no frame widget then
// there is no main frame. This only applies for widgets for frames.
CHECK(!is_swapped_out_);
CHECK(!is_frozen_);
if (owner_delegate_)
CHECK(GetFrameWidget());
if (for_oopif_)
if (for_child_local_root_frame_)
CHECK(GetFrameWidget());
// TODO(jonross): have this generated by the LayerTreeFrameSink itself, which
......@@ -1006,7 +1008,13 @@ void RenderWidget::RequestNewLayerTreeFrameSink(
// The |url| is not always available, fallback to a fixed string.
if (url.is_empty())
url = GURL("chrome://gpu/RenderWidget::RequestNewLayerTreeFrameSink");
const char* client_name = for_oopif_ ? kOOPIF : kRenderer;
// TODO(danakj): This may not be accurate, depending on the intent. A child
// local root could be in the same process as the view, so if the client is
// meant to designate the process type, it seems kRenderer would be the
// correct choice. If client is meant to designate the widget type, then
// kOOPIF would denote that it is not for the main frame. However, kRenderer
// would also be used for other widgets such as popups.
const char* client_name = for_child_local_root_frame_ ? kOOPIF : kRenderer;
RenderThreadImpl::current()->RequestNewLayerTreeFrameSink(
routing_id_, frame_swap_message_queue_, std::move(url),
std::move(callback), std::move(client_request), std::move(ptr),
......@@ -1536,7 +1544,7 @@ LayerTreeView* RenderWidget::InitializeLayerTreeView() {
compositor_deps_->GetTaskGraphRunner(),
compositor_deps_->GetWebMainThreadScheduler());
layer_tree_view_->Initialize(
GenerateLayerTreeSettings(compositor_deps_, for_oopif_,
GenerateLayerTreeSettings(compositor_deps_, for_child_local_root_frame_,
screen_info_.rect.size(),
screen_info_.device_scale_factor),
compositor_deps_->CreateUkmRecorderFactory());
......@@ -1553,7 +1561,7 @@ LayerTreeView* RenderWidget::InitializeLayerTreeView() {
if (!should_generate_frame_sink) {
// Prevents SetVisible() from blink from doing anything.
layer_tree_view_->SetNeverVisible();
} else if (!is_swapped_out_) {
} else if (!is_frozen_) {
// Begins the compositor's scheduler to start producing frames.
// Don't do this if the RenderWidget is attached to a RenderViewImpl for a
// remote main frame, as this RenderWidget is a zombie then, which won't be
......@@ -1589,10 +1597,10 @@ void RenderWidget::StopCompositor() {
layer_tree_view_->ReleaseLayerTreeFrameSink();
}
void RenderWidget::SetSwappedOut(bool is_swapped_out) {
DCHECK_NE(is_swapped_out, is_swapped_out_);
is_swapped_out_ = is_swapped_out;
if (is_swapped_out)
void RenderWidget::SetIsFrozen(bool is_frozen) {
DCHECK_NE(is_frozen, is_frozen_);
is_frozen_ = is_frozen;
if (is_frozen)
StopCompositor();
else
StartCompositor();
......@@ -1612,8 +1620,8 @@ void RenderWidget::NotifyOnClose() {
void RenderWidget::CloseWidgetSoon() {
DCHECK(content::RenderThread::Get());
if (is_swapped_out_) {
// This widget is currently swapped out, and the active widget is in a
if (is_frozen_) {
// This widget is currently not active. The active main frame widget is in a
// different process. Have the browser route the close request to the
// active widget instead, so that the correct unload handlers are run.
Send(new WidgetHostMsg_RouteCloseEvent(routing_id_));
......@@ -1633,9 +1641,9 @@ void RenderWidget::CloseWidgetSoon() {
}
void RenderWidget::Close() {
// This was done immediately in the |for_oopif_| case in the OnClose() IPC
// handler.
if (!for_oopif_)
// This was done immediately in the |for_child_local_root_frame_| case in the
// OnClose() IPC handler.
if (!for_child_local_root_frame_)
CloseWebWidget();
layer_tree_view_.reset();
......@@ -1775,9 +1783,9 @@ void RenderWidget::SetWindowRect(const WebRect& rect_in_screen) {
// This path is for the renderer to change the on-screen position/size of
// the widget by changing its window rect. This is not possible for
// RenderWidgets whose position/size are controlled by layout from another
// frame tree (ie. child local root frames, informed by |for_oopif_|), as
// the window rect can only be set by the browser.
if (for_oopif_)
// frame tree (ie. child local root frames), as the window rect can only be
// set by the browser.
if (for_child_local_root_frame_)
return;
WebRect window_rect = rect_in_screen;
......@@ -3258,8 +3266,9 @@ PepperPluginInstanceImpl* RenderWidget::GetFocusedPepperPluginInsideWidget() {
#endif
gfx::Rect RenderWidget::ViewportVisibleRect() {
return for_oopif_ ? compositor_visible_rect_
: gfx::Rect(compositor_viewport_pixel_size_);
return for_child_local_root_frame_
? compositor_visible_rect_
: gfx::Rect(compositor_viewport_pixel_size_);
}
// static
......
......@@ -157,7 +157,7 @@ class CONTENT_EXPORT RenderWidget
WidgetType widget_type,
const ScreenInfo& screen_info,
blink::WebDisplayMode display_mode,
bool swapped_out,
bool is_frozen,
bool hidden,
bool never_visible,
mojom::WidgetRequest widget_request = nullptr);
......@@ -221,13 +221,15 @@ class CONTENT_EXPORT RenderWidget
ScreenInfo screen_info() const { return screen_info_; }
void set_screen_info(const ScreenInfo& info) { screen_info_ = info; }
// Sets whether this RenderWidget has been swapped out to be displayed by
// a RenderWidget in a different process. If so, no new IPC messages will be
// sent (only ACKs) and the process is free to exit when there are no other
// active RenderWidgets. The RenderWidget is not used for compositing as there
// is no WebWidget that should display content when swapped out.
void SetSwappedOut(bool is_swapped_out);
bool is_swapped_out() const { return is_swapped_out_; }
// Sets whether this RenderWidget should be moved into or out of a frozen
// state. This state is used for the RenderWidget attached to a RenderViewImpl
// for its main frame, when there is no local main frame present.
// In this case, the RenderWidget can't be deleted currently but should
// otherwise act as if it is dead. Only whitelisted new IPC messages will be
// sent, and it does no compositing. The process is free to exit when there
// are no other unfrozen (thawed) RenderWidgets.
void SetIsFrozen(bool is_frozen);
bool is_frozen() const { return is_frozen_; }
// This is true once a Close IPC has been received. The actual action of
// closing must be done on another stack frame, in case the IPC receipt
......@@ -815,10 +817,14 @@ class CONTENT_EXPORT RenderWidget
// True if it is known that the host is in the process of being shut down.
bool host_will_close_this_;
// Whether this RenderWidget is currently swapped out, such that the view is
// being rendered by another process. If all RenderWidgets in a process are
// swapped out, the process can exit.
bool is_swapped_out_;
// A RenderWidget is frozen if it is the RenderWidget attached to the
// RenderViewImpl for its main frame, but there is a proxy main frame in
// RenderViewImpl's frame tree. Since proxy frames do not have content they
// do not need a RenderWidget.
// TODO(419087): In this case the RenderWidget should not exist at all as
// it has nothing to display, but since we can't destroy it without destroying
// the RenderViewImpl, we freeze it instead.
bool is_frozen_;
// Stores information about the current text input.
blink::WebTextInputInfo text_input_info_;
......@@ -913,8 +919,10 @@ class CONTENT_EXPORT RenderWidget
// Indicates whether this widget has focus.
bool has_focus_;
// Whether this RenderWidget is for an out-of-process iframe or not.
bool for_oopif_;
// Whether this widget is for a child local root frame. This excludes widgets
// that are not for a frame (eg popups) and excludes the widget for the main
// frame (which is attached to the RenderViewImpl).
bool for_child_local_root_frame_;
// A callback into the creator/opener of this widget, to be executed when
// WebWidgetClient::Show() occurs.
......
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