Commit d8d1f551 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

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: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793839}
parent b56d7e23
...@@ -71,12 +71,6 @@ IPC_MESSAGE_ROUTED0(WidgetMsg_SetBounds_ACK) ...@@ -71,12 +71,6 @@ IPC_MESSAGE_ROUTED0(WidgetMsg_SetBounds_ACK)
IPC_MESSAGE_ROUTED1(WidgetMsg_SetViewportIntersection, IPC_MESSAGE_ROUTED1(WidgetMsg_SetViewportIntersection,
blink::ViewportIntersectionState /* intersection_state */) 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. // Renderer -> Browser Messages.
// //
...@@ -105,7 +99,4 @@ IPC_MESSAGE_ROUTED2(WidgetHostMsg_FrameSwapMessages, ...@@ -105,7 +99,4 @@ IPC_MESSAGE_ROUTED2(WidgetHostMsg_FrameSwapMessages,
// Close message. // Close message.
IPC_MESSAGE_CONTROL1(WidgetHostMsg_Close_ACK, int /* old_route_id */) 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_ #endif // CONTENT_COMMON_WIDGET_MESSAGES_H_
...@@ -2635,40 +2635,25 @@ void RenderFrameSubmissionObserver::OnLocalSurfaceIdChanged( ...@@ -2635,40 +2635,25 @@ void RenderFrameSubmissionObserver::OnLocalSurfaceIdChanged(
MainThreadFrameObserver::MainThreadFrameObserver( MainThreadFrameObserver::MainThreadFrameObserver(
RenderWidgetHost* render_widget_host) RenderWidgetHost* render_widget_host)
: render_widget_host_(render_widget_host), : render_widget_host_(render_widget_host),
routing_id_(render_widget_host_->GetProcess()->GetNextRoutingID()) { 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);
}
MainThreadFrameObserver::~MainThreadFrameObserver() { MainThreadFrameObserver::~MainThreadFrameObserver() = default;
render_widget_host_->GetProcess()->RemoveRoute(routing_id_);
}
void MainThreadFrameObserver::Wait() { void MainThreadFrameObserver::Wait() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
render_widget_host_->Send(new WidgetMsg_WaitForNextFrameForTests( static_cast<RenderWidgetHostImpl*>(render_widget_host_)
render_widget_host_->GetRoutingID(), routing_id_)); ->InsertVisualStateCallback(base::BindOnce(&MainThreadFrameObserver::Quit,
base::Unretained(this)));
base::RunLoop run_loop; base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure(); quit_closure_ = run_loop.QuitClosure();
run_loop.Run(); run_loop.Run();
} }
void MainThreadFrameObserver::Quit() { void MainThreadFrameObserver::Quit(bool) {
if (quit_closure_) if (quit_closure_)
std::move(quit_closure_).Run(); 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, InputMsgWatcher::InputMsgWatcher(RenderWidgetHost* render_widget_host,
blink::WebInputEvent::Type type) blink::WebInputEvent::Type type)
: render_widget_host_(render_widget_host), : render_widget_host_(render_widget_host),
......
...@@ -1308,20 +1308,17 @@ class RenderFrameSubmissionObserver ...@@ -1308,20 +1308,17 @@ class RenderFrameSubmissionObserver
// So while the ACK can arrive before a CompositorFrame submission occurs. The // So while the ACK can arrive before a CompositorFrame submission occurs. The
// processing does not occur until after the FrameToken for that frame // processing does not occur until after the FrameToken for that frame
// submission arrives to the main thread. // submission arrives to the main thread.
class MainThreadFrameObserver : public IPC::Listener { class MainThreadFrameObserver {
public: public:
explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host); explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host);
~MainThreadFrameObserver() override; ~MainThreadFrameObserver();
// Synchronizes the browser main thread with the renderer main thread and impl // Synchronizes the browser main thread with the renderer main thread and impl
// thread. // thread.
void Wait(); void Wait();
// Overridden IPC::Listener methods.
bool OnMessageReceived(const IPC::Message& msg) override;
private: private:
void Quit(); void Quit(bool);
RenderWidgetHost* render_widget_host_; RenderWidgetHost* render_widget_host_;
base::OnceClosure quit_closure_; base::OnceClosure quit_closure_;
......
...@@ -435,8 +435,6 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) { ...@@ -435,8 +435,6 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(WidgetMsg_SetBounds_ACK, OnRequestSetBoundsAck) IPC_MESSAGE_HANDLER(WidgetMsg_SetBounds_ACK, OnRequestSetBoundsAck)
IPC_MESSAGE_HANDLER(WidgetMsg_SetViewportIntersection, IPC_MESSAGE_HANDLER(WidgetMsg_SetViewportIntersection,
OnSetViewportIntersection) OnSetViewportIntersection)
IPC_MESSAGE_HANDLER(WidgetMsg_WaitForNextFrameForTests,
OnWaitNextFrameForTests)
IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
...@@ -1651,13 +1649,6 @@ void RenderWidget::UnregisterRenderFrame(RenderFrameImpl* frame) { ...@@ -1651,13 +1649,6 @@ void RenderWidget::UnregisterRenderFrame(RenderFrameImpl* frame) {
render_frames_.RemoveObserver(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 { const blink::ScreenInfo& RenderWidget::GetOriginalScreenInfo() const {
if (device_emulator_) if (device_emulator_)
return device_emulator_->original_screen_info(); return device_emulator_->original_screen_info();
......
...@@ -479,7 +479,6 @@ class CONTENT_EXPORT RenderWidget ...@@ -479,7 +479,6 @@ class CONTENT_EXPORT RenderWidget
const gfx::PointF& screen_point, const gfx::PointF& screen_point,
blink::WebDragOperation drag_operation); blink::WebDragOperation drag_operation);
void OnOrientationChange(); void OnOrientationChange();
void OnWaitNextFrameForTests(int routing_id);
// Sets the "hidden" state of this widget. All modification of is_hidden_ // 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 // 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