Commit 70ee8e77 authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Ensure capture params exist

It is possible capture params don't exist when they were modified here.
Make sure that they exist.

This is causing a very low volume of crashes on Canary. I think when the
directory fails to be created.

Change-Id: I8481e19b927f6dd4a8c8b8740aacb6faa1b31744
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518031Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823745}
parent 0b7197a2
......@@ -423,9 +423,6 @@ void PaintPreviewClient::RequestCaptureOnUIThread(
mojom::PaintPreviewStatus status,
mojom::PaintPreviewCaptureParamsPtr capture_params) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// For the main frame, apply a clip rect if one is provided.
if (params.is_main_frame)
capture_params->clip_rect_is_hint = false;
auto it = all_document_data_.find(params.document_guid);
if (it == all_document_data_.end())
......@@ -442,8 +439,10 @@ void PaintPreviewClient::RequestCaptureOnUIThread(
// If the render frame host navigated or is no longer around treat this as a
// failure as a navigation occurring during capture is bad.
auto* render_frame_host = content::RenderFrameHost::FromID(render_frame_id);
if (!render_frame_host || render_frame_host->GetEmbeddingToken().value_or(
base::UnguessableToken::Null()) != frame_guid) {
if (!render_frame_host ||
render_frame_host->GetEmbeddingToken().value_or(
base::UnguessableToken::Null()) != frame_guid ||
!capture_params) {
std::move(document_data->callback)
.Run(params.document_guid, mojom::PaintPreviewStatus::kCaptureFailed,
{});
......@@ -466,6 +465,11 @@ void PaintPreviewClient::RequestCaptureOnUIThread(
render_frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
&interface_ptrs_[frame_guid]);
}
// For the main frame, apply a clip rect if one is provided.
if (params.is_main_frame)
capture_params->clip_rect_is_hint = false;
interface_ptrs_[frame_guid]->CapturePaintPreview(
std::move(capture_params),
base::BindOnce(&PaintPreviewClient::OnPaintPreviewCapturedCallback,
......
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