Commit 181802cc authored by Igor Bukanov's avatar Igor Bukanov Committed by Commit Bot

EndDrag should use weak_ptr for its arg

As WebContentsViewAura::EndDrag can be arbitrary delayed waiting for the
renderer process to perform asynchronous targetting, it should use a
weak pointer for the RenderWidgetHostImpl argument.

Bug: 1034519
Change-Id: Ib8c785d3c54b448dc4b020b11112b65ced3d4261
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978000Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744297}
parent c9f3f1e2
......@@ -722,8 +722,9 @@ void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) {
rwhv->SetSize(size);
}
void WebContentsViewAura::EndDrag(RenderWidgetHost* source_rwh,
blink::WebDragOperationsMask ops) {
void WebContentsViewAura::EndDrag(
base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr,
blink::WebDragOperationsMask ops) {
drag_start_process_id_ = ChildProcessHost::kInvalidUniqueID;
drag_start_view_id_ = GlobalRoutingID(ChildProcessHost::kInvalidUniqueID,
MSG_ROUTING_NONE);
......@@ -731,6 +732,9 @@ void WebContentsViewAura::EndDrag(RenderWidgetHost* source_rwh,
if (!web_contents_)
return;
// It is OK for source_rwh to be null.
RenderWidgetHost* source_rwh = source_rwh_weak_ptr.get();
aura::Window* window = GetContentNativeView();
gfx::PointF screen_loc =
gfx::PointF(display::Screen::GetScreen()->GetCursorScreenPoint());
......@@ -1110,11 +1114,11 @@ void WebContentsViewAura::StartDragging(
// callback yet. So we have to make sure to delay calling EndDrag until drop
// is done.
if (!drag_in_progress_)
EndDrag(source_rwh_weak_ptr.get(), ConvertToWeb(result_op));
EndDrag(std::move(source_rwh_weak_ptr), ConvertToWeb(result_op));
else
end_drag_runner_ = base::ScopedClosureRunner(base::BindOnce(
&WebContentsViewAura::EndDrag, weak_ptr_factory_.GetWeakPtr(),
source_rwh_weak_ptr.get(), ConvertToWeb(result_op)));
std::move(source_rwh_weak_ptr), ConvertToWeb(result_op)));
}
void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) {
......
......@@ -108,7 +108,8 @@ class CONTENT_EXPORT WebContentsViewAura
void SizeChangedCommon(const gfx::Size& size);
void EndDrag(RenderWidgetHost* source_rwh, blink::WebDragOperationsMask ops);
void EndDrag(base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr,
blink::WebDragOperationsMask ops);
void InstallOverscrollControllerDelegate(RenderWidgetHostViewAura* view);
......
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