Commit 65b5bcab authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Avoid obscure compositor failure

If there is no GUID for the root frame the IPC will fail due to sending
a null token. This CL ensures that doesn't occur.

Change-Id: I5861a96f244c77592e595d922cae0e183103f92a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300260
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789114}
parent 5f6a414d
...@@ -120,6 +120,9 @@ void PaintPreviewCompositorImpl::BeginComposite( ...@@ -120,6 +120,9 @@ void PaintPreviewCompositorImpl::BeginComposite(
auto response = mojom::PaintPreviewBeginCompositeResponse::New(); auto response = mojom::PaintPreviewBeginCompositeResponse::New();
auto mapping = request->proto.Map(); auto mapping = request->proto.Map();
if (!mapping.IsValid()) { if (!mapping.IsValid()) {
DVLOG(1) << "Failed to map proto in shared memory.";
// Cannot send a null token over mojo. This will be ignored downstream.
response->root_frame_guid = base::UnguessableToken::Create();
std::move(callback).Run( std::move(callback).Run(
mojom::PaintPreviewCompositor::Status::kDeserializingFailure, mojom::PaintPreviewCompositor::Status::kDeserializingFailure,
std::move(response)); std::move(response));
...@@ -130,11 +133,24 @@ void PaintPreviewCompositorImpl::BeginComposite( ...@@ -130,11 +133,24 @@ void PaintPreviewCompositorImpl::BeginComposite(
bool ok = paint_preview.ParseFromArray(mapping.memory(), mapping.size()); bool ok = paint_preview.ParseFromArray(mapping.memory(), mapping.size());
if (!ok) { if (!ok) {
DVLOG(1) << "Failed to parse proto."; DVLOG(1) << "Failed to parse proto.";
// Cannot send a null token over mojo. This will be ignored downstream.
response->root_frame_guid = base::UnguessableToken::Create();
std::move(callback).Run( std::move(callback).Run(
mojom::PaintPreviewCompositor::Status::kDeserializingFailure, mojom::PaintPreviewCompositor::Status::kDeserializingFailure,
std::move(response)); std::move(response));
return; return;
} }
response->root_frame_guid = base::UnguessableToken::Deserialize(
paint_preview.root_frame().embedding_token_high(),
paint_preview.root_frame().embedding_token_low());
if (response->root_frame_guid.is_empty()) {
DVLOG(1) << "No valid root frame guid";
// Cannot send a null token over mojo. This will be ignored downstream.
response->root_frame_guid = base::UnguessableToken::Create();
std::move(callback).Run(
mojom::PaintPreviewCompositor::Status::kDeserializingFailure,
std::move(response));
}
auto frames = DeserializeAllFrames(&request->file_map); auto frames = DeserializeAllFrames(&request->file_map);
// Adding the root frame must succeed. // Adding the root frame must succeed.
...@@ -145,9 +161,6 @@ void PaintPreviewCompositorImpl::BeginComposite( ...@@ -145,9 +161,6 @@ void PaintPreviewCompositorImpl::BeginComposite(
std::move(response)); std::move(response));
return; return;
} }
response->root_frame_guid = base::UnguessableToken::Deserialize(
paint_preview.root_frame().embedding_token_high(),
paint_preview.root_frame().embedding_token_low());
// Adding subframes is optional. // Adding subframes is optional.
for (const auto& subframe_proto : paint_preview.subframes()) for (const auto& subframe_proto : paint_preview.subframes())
......
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