Commit b7abbb3d authored by Fergal Daly's avatar Fergal Daly Committed by Chromium LUCI CQ

Reland "[Paint Preview] Post task captured callback"

This is a reland of c669ac6b

This is only the fix and not the test.

Original change's description:
> [Paint Preview] Post task captured callback
>
> This CL attempts to fix a bug where calling
> WebContents::DecrementCapturerCount in the callback passed to
> PaintPreviewClient can result in reloading a crashed render frame.
> This is problematic and crashes if it occurs inside RenderFrameDeleted
> and PaintPreviewClient::OnFinished is invoked. By posting the callback
> it should be invoked after RenderFrameDeleted cleanup is done resulting
> in DecrementCapturerCount no longer being called inside
> RenderFrameDeleted.
>
> Bug: 1146573
> Change-Id: Iccb612d89135e058d8fc06de018e7c95cd91657a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595247
> Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
> Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
> Reviewed-by: Mehran Mahmoudi <mahmoudi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#837649}

Bug: 1146573
Change-Id: I19623734e3c16b8646c286f47420a432647e0e24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596727
Auto-Submit: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838141}
parent 7447e48c
...@@ -560,16 +560,18 @@ void PaintPreviewClient::OnFinished( ...@@ -560,16 +560,18 @@ void PaintPreviewClient::OnFinished(
// At a minimum one frame was captured successfully, it is up to the // At a minimum one frame was captured successfully, it is up to the
// caller to decide if a partial success is acceptable based on what is // caller to decide if a partial success is acceptable based on what is
// contained in the proto. // contained in the proto.
std::move(document_data->callback) base::SequencedTaskRunnerHandle::Get()->PostTask(
.Run(guid, FROM_HERE,
base::BindOnce(std::move(document_data->callback), guid,
document_data->had_error document_data->had_error
? mojom::PaintPreviewStatus::kPartialSuccess ? mojom::PaintPreviewStatus::kPartialSuccess
: mojom::PaintPreviewStatus::kOk, : mojom::PaintPreviewStatus::kOk,
std::move(*document_data).IntoCaptureResult()); std::move(*document_data).IntoCaptureResult()));
} else { } else {
// A proto could not be created indicating all frames failed to capture. // A proto could not be created indicating all frames failed to capture.
std::move(document_data->callback) base::SequencedTaskRunnerHandle::Get()->PostTask(
.Run(guid, mojom::PaintPreviewStatus::kFailed, {}); FROM_HERE, base::BindOnce(std::move(document_data->callback), guid,
mojom::PaintPreviewStatus::kFailed, nullptr));
} }
all_document_data_.erase(guid); all_document_data_.erase(guid);
} }
......
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