Commit 3c1fc1fd authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Reland "Reland "Convert WidgetMsg_WaitForNextFrameForTest to mojo""

This is a reland of d8d1f551

Original change's description:
> Reland "Convert WidgetMsg_WaitForNextFrameForTest to mojo"
> 
> This is a reland of 75391394.
> 
> Reason for reland:
> - Fixed a flaky test failures in crrev.com/c/2309317
> - No changes in this CL between original & reland.
> 
> Original change's description:
> > Convert WidgetMsg_WaitForNextFrameForTest to mojo
> >
> > This CL uses VisualStateRequest Mojo API in FrameWidget mojo interface
> > introduced at https://crrev.com/c/2178480 since
> > WidgetMsg_WaitForNextFrameForTest has the same implementation with
> > VisualStateRequest Mojo API notifying that the frame swap has occurred.
> >
> > Bug: 1071588
> > Change-Id: If317b98320ec3fb85fcf7a5d1e39f0fa202d4cde
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216145
> > Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
> > Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> > Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#789910}
> 
> Bug: 1071588
> Change-Id: I7ade2819495cddf87862054095db361e0511dcf5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2309497
> Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#793839}

Bug: 1071588
Change-Id: I9499c2b89eb892b9275f9fa7f0445858ea5b5bec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342333
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798575}
parent 714925a1
......@@ -71,12 +71,6 @@ IPC_MESSAGE_ROUTED0(WidgetMsg_SetBounds_ACK)
IPC_MESSAGE_ROUTED1(WidgetMsg_SetViewportIntersection,
blink::ViewportIntersectionState /* intersection_state */)
// Sent by the browser to synchronize with the next compositor frame by
// requesting an ACK be queued. Used only for tests.
IPC_MESSAGE_ROUTED1(WidgetMsg_WaitForNextFrameForTests,
int /* main_frame_thread_observer_routing_id */)
//
// Renderer -> Browser Messages.
//
......@@ -105,7 +99,4 @@ IPC_MESSAGE_ROUTED2(WidgetHostMsg_FrameSwapMessages,
// Close message.
IPC_MESSAGE_CONTROL1(WidgetHostMsg_Close_ACK, int /* old_route_id */)
// Sent in reply to WidgetMsg_WaitForNextFrameForTests.
IPC_MESSAGE_ROUTED0(WidgetHostMsg_WaitForNextFrameForTests_ACK)
#endif // CONTENT_COMMON_WIDGET_MESSAGES_H_
......@@ -2641,40 +2641,25 @@ void RenderFrameSubmissionObserver::OnLocalSurfaceIdChanged(
MainThreadFrameObserver::MainThreadFrameObserver(
RenderWidgetHost* render_widget_host)
: render_widget_host_(render_widget_host),
routing_id_(render_widget_host_->GetProcess()->GetNextRoutingID()) {
// TODO(lfg): We should look into adding a way to observe RenderWidgetHost
// messages similarly to what WebContentsObserver can do with RFH and RVW.
render_widget_host_->GetProcess()->AddRoute(routing_id_, this);
}
routing_id_(render_widget_host_->GetProcess()->GetNextRoutingID()) {}
MainThreadFrameObserver::~MainThreadFrameObserver() {
render_widget_host_->GetProcess()->RemoveRoute(routing_id_);
}
MainThreadFrameObserver::~MainThreadFrameObserver() = default;
void MainThreadFrameObserver::Wait() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
render_widget_host_->Send(new WidgetMsg_WaitForNextFrameForTests(
render_widget_host_->GetRoutingID(), routing_id_));
static_cast<RenderWidgetHostImpl*>(render_widget_host_)
->InsertVisualStateCallback(base::BindOnce(&MainThreadFrameObserver::Quit,
base::Unretained(this)));
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
run_loop.Run();
}
void MainThreadFrameObserver::Quit() {
void MainThreadFrameObserver::Quit(bool) {
if (quit_closure_)
std::move(quit_closure_).Run();
}
bool MainThreadFrameObserver::OnMessageReceived(const IPC::Message& msg) {
if (msg.type() == WidgetHostMsg_WaitForNextFrameForTests_ACK::ID &&
msg.routing_id() == routing_id_) {
GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(&MainThreadFrameObserver::Quit, base::Unretained(this)));
}
return true;
}
InputMsgWatcher::InputMsgWatcher(RenderWidgetHost* render_widget_host,
blink::WebInputEvent::Type type)
: render_widget_host_(render_widget_host),
......
......@@ -1313,20 +1313,17 @@ class RenderFrameSubmissionObserver
// So while the ACK can arrive before a CompositorFrame submission occurs. The
// processing does not occur until after the FrameToken for that frame
// submission arrives to the main thread.
class MainThreadFrameObserver : public IPC::Listener {
class MainThreadFrameObserver {
public:
explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host);
~MainThreadFrameObserver() override;
~MainThreadFrameObserver();
// Synchronizes the browser main thread with the renderer main thread and impl
// thread.
void Wait();
// Overridden IPC::Listener methods.
bool OnMessageReceived(const IPC::Message& msg) override;
private:
void Quit();
void Quit(bool);
RenderWidgetHost* render_widget_host_;
base::OnceClosure quit_closure_;
......
......@@ -434,8 +434,6 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(WidgetMsg_SetBounds_ACK, OnRequestSetBoundsAck)
IPC_MESSAGE_HANDLER(WidgetMsg_SetViewportIntersection,
OnSetViewportIntersection)
IPC_MESSAGE_HANDLER(WidgetMsg_WaitForNextFrameForTests,
OnWaitNextFrameForTests)
IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
......@@ -1523,13 +1521,6 @@ void RenderWidget::UnregisterRenderFrame(RenderFrameImpl* frame) {
render_frames_.RemoveObserver(frame);
}
void RenderWidget::OnWaitNextFrameForTests(
int main_frame_thread_observer_routing_id) {
// Sends an ACK to the browser process during the next compositor frame.
QueueMessage(std::make_unique<WidgetHostMsg_WaitForNextFrameForTests_ACK>(
main_frame_thread_observer_routing_id));
}
const blink::ScreenInfo& RenderWidget::GetOriginalScreenInfo() const {
if (device_emulator_)
return device_emulator_->original_screen_info();
......
......@@ -454,7 +454,6 @@ class CONTENT_EXPORT RenderWidget
const gfx::PointF& screen_point,
blink::WebDragOperation drag_operation);
void OnOrientationChange();
void OnWaitNextFrameForTests(int routing_id);
// Sets the "hidden" state of this widget. All modification of is_hidden_
// should use this method so that we can properly inform the RenderThread of
......
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