fix: headless job tracking in printToPDF (#36064)

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2022-10-20 14:28:21 -04:00
committed by GitHub
parent c8c335874a
commit bcfafc4386

View File

@@ -124,6 +124,7 @@ void PrintViewManagerElectron::PrintToPdf(
printing_rfh_ = rfh;
print_pages_params->pages = absl::get<printing::PageRanges>(parsed_ranges);
headless_jobs_.emplace_back(print_pages_params->params->document_cookie);
callback_ = std::move(callback);
// There is no need for a weak pointer here since the mojo proxy is held
@@ -147,7 +148,9 @@ void PrintViewManagerElectron::OnDidPrintWithParams(
}
}
auto& content = *result->get_params()->content;
printing::mojom::DidPrintDocumentParamsPtr& params = result->get_params();
auto& content = *params->content;
if (!content.metafile_data_region.IsValid()) {
FailJob(kInvalidMemoryHandle);
return;
@@ -163,7 +166,7 @@ void PrintViewManagerElectron::OnDidPrintWithParams(
std::string(static_cast<const char*>(map.memory()), map.size());
std::move(callback_).Run(kPrintSuccess,
base::RefCountedString::TakeString(&data));
base::Erase(headless_jobs_, params->document_cookie);
Reset();
}