Commit 436cbf17 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

RenderWidget no longer has routing IDs.

All IPC messages for RenderWidgets have been moved to mojo. The routing
ID is no longer used inside RenderWidget (it still defines the
viz::FrameSinkId) so it can't be removed from the IPC messages yet. A
followup change will make CreateNewPopupWidget async.

BUG=1097816

Change-Id: I6cd6c9c49031c29aa8f97f0e6a9246c7c0338b78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510769
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822812}
parent 21fa1d83
......@@ -1590,7 +1590,6 @@ RenderFrameImpl* RenderFrameImpl::CreateMainFrame(
render_frame->frame_->SetCommittedFirstRealLoad();
std::unique_ptr<RenderWidget> render_widget = RenderWidget::CreateForFrame(
agent_scheduling_group, params->main_frame_widget_routing_id,
compositor_deps);
// Non-owning pointer that is self-referencing and destroyed by calling
......@@ -1763,8 +1762,8 @@ void RenderFrameImpl::CreateFrame(
// TODO(crbug.com/419087): Can we merge this code with
// RenderFrameImpl::CreateMainFrame()?
std::unique_ptr<RenderWidget> render_widget = RenderWidget::CreateForFrame(
agent_scheduling_group, widget_params->routing_id, compositor_deps);
std::unique_ptr<RenderWidget> render_widget =
RenderWidget::CreateForFrame(compositor_deps);
// Non-owning pointer that is self-referencing and destroyed by calling
// Close(). The RenderViewImpl has a RenderWidget already, but not a
......@@ -1814,8 +1813,8 @@ void RenderFrameImpl::CreateFrame(
// Makes a new RenderWidget for the child local root. It provides the
// local root with a new compositing, painting, and input coordinate
// space/context.
std::unique_ptr<RenderWidget> render_widget = RenderWidget::CreateForFrame(
agent_scheduling_group, widget_params->routing_id, compositor_deps);
std::unique_ptr<RenderWidget> render_widget =
RenderWidget::CreateForFrame(compositor_deps);
// Non-owning pointer that is self-referencing and destroyed by calling
// Close(). We use the new RenderWidget as the client for this
......
......@@ -533,8 +533,7 @@ blink::WebPagePopup* RenderViewImpl::CreatePopup(
RenderFrameImpl::FromWebFrame(creator)->GetLocalRootRenderWidget();
RenderWidget* popup_widget =
RenderWidget::CreateForPopup(agent_scheduling_group_, widget_routing_id,
opener_render_widget->compositor_deps());
RenderWidget::CreateForPopup(opener_render_widget->compositor_deps());
// The returned WebPagePopup is self-referencing, so the pointer here is not
// an owning pointer. It is de-referenced by calling Close().
......
......@@ -13,28 +13,16 @@
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/ukm_manager.h"
#include "content/renderer/agent_scheduling_group.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/buildflags/buildflags.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/web_rect.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_page_popup.h"
#include "third_party/blink/public/web/web_widget.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/gfx/geometry/rect_conversions.h"
using blink::WebNavigationPolicy;
using blink::WebString;
namespace content {
namespace {
......@@ -53,33 +41,21 @@ void RenderWidget::InstallCreateForFrameHook(
}
std::unique_ptr<RenderWidget> RenderWidget::CreateForFrame(
AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps) {
if (g_create_render_widget_for_frame) {
return g_create_render_widget_for_frame(agent_scheduling_group,
widget_routing_id, compositor_deps);
return g_create_render_widget_for_frame(compositor_deps);
}
return std::make_unique<RenderWidget>(agent_scheduling_group,
widget_routing_id, compositor_deps);
return std::make_unique<RenderWidget>(compositor_deps);
}
RenderWidget* RenderWidget::CreateForPopup(
AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps) {
return new RenderWidget(agent_scheduling_group, widget_routing_id,
compositor_deps);
return new RenderWidget(compositor_deps);
}
RenderWidget::RenderWidget(AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps)
: agent_scheduling_group_(agent_scheduling_group),
routing_id_(widget_routing_id),
compositor_deps_(compositor_deps) {
DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
RenderWidget::RenderWidget(CompositorDependencies* compositor_deps)
: compositor_deps_(compositor_deps) {
DCHECK(RenderThread::IsMainThread());
DCHECK(compositor_deps_);
}
......@@ -120,11 +96,8 @@ void RenderWidget::CloseForFrame(std::unique_ptr<RenderWidget> widget) {
void RenderWidget::Initialize(blink::WebWidget* web_widget,
const blink::ScreenInfo& screen_info) {
DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
DCHECK(web_widget);
agent_scheduling_group_.AddRoute(routing_id_, this);
webwidget_ = web_widget;
if (auto* scheduler_state = GetWebWidget()->RendererWidgetSchedulingState())
scheduler_state->SetHidden(web_widget->IsHidden());
......@@ -140,23 +113,6 @@ void RenderWidget::Initialize(blink::WebWidget* web_widget,
web_widget->SetCompositorVisible(true);
}
bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
return false;
}
bool RenderWidget::Send(IPC::Message* message) {
// Provisional frames don't send IPCs until they are swapped in/committed.
CHECK(!IsForProvisionalFrame());
// Don't send any messages during shutdown.
DCHECK(!closing_);
// If given a messsage without a routing ID, then assign our routing ID.
if (message->routing_id() == MSG_ROUTING_NONE)
message->set_routing_id(routing_id_);
return agent_scheduling_group_.Send(message);
}
void RenderWidget::BrowserClosedIpcChannelForPopupWidget() {
DCHECK(for_popup_);
......@@ -204,11 +160,6 @@ void RenderWidget::Close(std::unique_ptr<RenderWidget> widget) {
closing_ = true;
// Browser correspondence is no longer needed at this point.
if (routing_id_ != MSG_ROUTING_NONE) {
agent_scheduling_group_.RemoveRoute(routing_id_);
}
webwidget_->Close(compositor_deps_->GetCleanupTaskRunner());
webwidget_ = nullptr;
......@@ -225,17 +176,6 @@ blink::WebFrameWidget* RenderWidget::GetFrameWidget() const {
return static_cast<blink::WebFrameWidget*>(webwidget_);
}
bool RenderWidget::IsForProvisionalFrame() const {
if (!for_frame())
return false;
// No widget here means the main frame is remote and there is no
// provisional frame at the moment.
if (!webwidget_)
return false;
auto* frame_widget = static_cast<blink::WebFrameWidget*>(webwidget_);
return frame_widget->LocalRoot()->IsProvisional();
}
void RenderWidget::ConvertViewportToWindow(blink::WebRect* rect) {
if (compositor_deps_->IsUseZoomForDSFEnabled()) {
float reverse =
......
......@@ -64,7 +64,6 @@ class WebPagePopup;
} // namespace blink
namespace content {
class AgentSchedulingGroup;
class CompositorDependencies;
class RenderFrameImpl;
class RenderFrameProxy;
......@@ -89,22 +88,16 @@ class RenderWidgetDelegate;
// RenderWidget is used to route input and graphical output between the browser
// and the renderer.
class CONTENT_EXPORT RenderWidget
: public IPC::Listener,
public IPC::Sender,
public blink::WebPagePopupClient { // Is-a WebWidgetClient also
: public blink::WebPagePopupClient { // Is-a WebWidgetClient also
public:
RenderWidget(AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps);
explicit RenderWidget(CompositorDependencies* compositor_deps);
~RenderWidget() override;
// Convenience type for creation method taken by InstallCreateForFrameHook().
// The method signature matches the RenderWidget constructor.
using CreateRenderWidgetFunction =
std::unique_ptr<RenderWidget> (*)(AgentSchedulingGroup&,
int32_t routing_id,
CompositorDependencies*);
std::unique_ptr<RenderWidget> (*)(CompositorDependencies*);
// Overrides the implementation of CreateForFrame() function below. Used by
// web tests to return a partial fake of RenderWidget.
static void InstallCreateForFrameHook(
......@@ -114,8 +107,6 @@ class CONTENT_EXPORT RenderWidget
// Testing infrastructure, such as test_runner, can override this function
// by calling InstallCreateForFrameHook().
static std::unique_ptr<RenderWidget> CreateForFrame(
AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps);
// Creates a RenderWidget for a popup. This is separate from CreateForFrame()
......@@ -125,8 +116,6 @@ class CONTENT_EXPORT RenderWidget
// object can request its own destruction via
// blink::mojom::PopupWidgetHost::RequestClose().
static RenderWidget* CreateForPopup(
AgentSchedulingGroup& agent_scheduling_group,
int32_t widget_routing_id,
CompositorDependencies* compositor_deps);
// Initialize a new RenderWidget for a popup. The |show_callback| is called
......@@ -154,28 +143,12 @@ class CONTENT_EXPORT RenderWidget
// passed into this object to asynchronously delete itself.
void CloseForFrame(std::unique_ptr<RenderWidget> widget);
int32_t routing_id() const { return routing_id_; }
CompositorDependencies* compositor_deps() const { return compositor_deps_; }
// This can return nullptr while the RenderWidget is closing. When for_frame()
// is true, the widget returned is a blink::WebFrameWidget.
blink::WebWidget* GetWebWidget() const { return webwidget_; }
// A main frame RenderWidget is destroyed and recreated using the same routing
// id. So messages en route to a destroyed RenderWidget may end up being
// received by a provisional RenderWidget, even though we don't normally
// communicate with a RenderWidget for a provisional frame. This can be used
// to avoid that race condition of acting on IPC messages meant for a
// destroyed RenderWidget.
bool IsForProvisionalFrame() const;
// IPC::Listener
bool OnMessageReceived(const IPC::Message& msg) override;
// IPC::Sender
bool Send(IPC::Message* msg) override;
// blink::WebWidgetClient
void ScheduleAnimation() override;
void BrowserClosedIpcChannelForPopupWidget() override;
......@@ -226,13 +199,6 @@ class CONTENT_EXPORT RenderWidget
// (via delegate_) and subframes (via for_child_local_root_frame_).
bool for_frame() const { return delegate_ || for_child_local_root_frame_; }
// The `AgentSchedulingGroup` this widget is associated with.
AgentSchedulingGroup& agent_scheduling_group_;
// Routing ID that allows us to communicate to the parent browser process
// RenderWidgetHost.
const int32_t routing_id_;
// Dependencies for initializing a compositor, including flags for optional
// features.
CompositorDependencies* const compositor_deps_;
......@@ -254,9 +220,6 @@ class CONTENT_EXPORT RenderWidget
// verify destruction always goes through Close().
bool closing_ = false;
// The time spent in input handlers this frame. Used to throttle input acks.
base::TimeDelta total_input_handling_time_this_frame_;
// 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).
......
......@@ -59,11 +59,8 @@ RenderViewImpl* CreateWebViewTestProxy(
}
std::unique_ptr<RenderWidget> CreateWebWidgetTestProxy(
AgentSchedulingGroup& agent_scheduling_group,
int32_t routing_id,
CompositorDependencies* compositor_deps) {
return std::make_unique<WebWidgetTestProxy>(agent_scheduling_group,
routing_id, compositor_deps);
return std::make_unique<WebWidgetTestProxy>(compositor_deps);
}
RenderFrameImpl* CreateWebFrameTestProxy(RenderFrameImpl::CreateParams 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