Commit 9e93f320 authored by danakj's avatar danakj Committed by Commit Bot

Don't post-task WidgetHostMsg_Close through RenderWidget

We don't want to Send() IPCs on a frozen/provisional RenderWidget. The
DoDeferredClose path in RenderWidget needs to send the IPC from a fresh
call stack, but in the meantime, the RenderWidget may have become
frozen (the main frame may have been swapped out in that RenderWidget's
RenderView).

In that case, we still allow the WidgetHostMsg_Close to go through, and
behave as if the IPC was already in transit to the browser. But since
RenderWidget::Send() should not be used, we use a static method.

This is one step toward allowing us to CHECK() that we don't Send()
IPCs from frozen/provisional RenderWidgets.

R=dcheng@chromium.org

Bug: 419087, 745091
Change-Id: I85f707c3c9bf071f7adf6273d78d40a6f530b10b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733852
Auto-Submit: danakj <danakj@chromium.org>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683782}
parent 2d3b8946
...@@ -1890,8 +1890,13 @@ void RenderWidget::AbortWarmupCompositor() { ...@@ -1890,8 +1890,13 @@ void RenderWidget::AbortWarmupCompositor() {
std::move(after_warmup_callback_).Run(nullptr); std::move(after_warmup_callback_).Run(nullptr);
} }
void RenderWidget::DoDeferredClose() { // static
Send(new WidgetHostMsg_Close(routing_id_)); void RenderWidget::DoDeferredClose(int widget_routing_id) {
// DoDeferredClose() was a posted task, which means the RenderWidget may have
// become frozen in the meantime. Frozen RenderWidgets do not send messages,
// so break the dependency on RenderWidget here, by making this method static
// and going to RenderThread directly to send.
RenderThread::Get()->Send(new WidgetHostMsg_Close(widget_routing_id));
} }
void RenderWidget::ClosePopupWidgetSoon() { void RenderWidget::ClosePopupWidgetSoon() {
...@@ -1922,7 +1927,7 @@ void RenderWidget::CloseWidgetSoon() { ...@@ -1922,7 +1927,7 @@ void RenderWidget::CloseWidgetSoon() {
// message back to the message loop, which won't run until the JS is // message back to the message loop, which won't run until the JS is
// complete, and then the Close request can be sent. // complete, and then the Close request can be sent.
GetCleanupTaskRunner()->PostTask( GetCleanupTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&RenderWidget::DoDeferredClose, this)); FROM_HERE, base::BindOnce(&RenderWidget::DoDeferredClose, routing_id_));
} }
void RenderWidget::Close() { void RenderWidget::Close() {
......
...@@ -737,7 +737,7 @@ class CONTENT_EXPORT RenderWidget ...@@ -737,7 +737,7 @@ class CONTENT_EXPORT RenderWidget
// Request the window to close from the renderer by sending the request to the // Request the window to close from the renderer by sending the request to the
// browser. // browser.
void DoDeferredClose(); static void DoDeferredClose(int widget_routing_id);
gfx::Size GetSizeForWebWidget() const; gfx::Size GetSizeForWebWidget() const;
void ResizeWebWidget(); void ResizeWebWidget();
......
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