Skip to content

Commit

Permalink
fix: headless job tracking in printToPDF (#36064)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
trop[bot] and codebytere committed Oct 20, 2022
1 parent c8c3358 commit bcfafc4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shell/browser/printing/print_view_manager_electron.cc
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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();
}

Expand Down

0 comments on commit bcfafc4

Please sign in to comment.