Skip to content

Commit

Permalink
fix: headless job tracking in printToPDF
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Oct 17, 2022
1 parent dc5d27a commit 28495db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shell/browser/printing/print_view_manager_electron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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 @@ -152,7 +153,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 @@ -169,6 +172,10 @@ void PrintViewManagerElectron::OnDidPrintWithParams(
std::move(callback_).Run(kPrintSuccess,
base::RefCountedString::TakeString(&data));

headless_jobs_.erase(std::remove(headless_jobs_.begin(), headless_jobs_.end(),
params->document_cookie),
headless_jobs_.end());

Reset();
}

Expand Down

0 comments on commit 28495db

Please sign in to comment.