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 108d685
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shell/browser/printing/print_view_manager_electron.cc
Expand Up @@ -126,6 +126,8 @@ void PrintViewManagerElectron::PrintToPdf(

printing_rfh_ = rfh;
print_pages_params->pages = absl::get<printing::PageRanges>(parsed_ranges);
int cookie = print_pages_params->params->document_cookie;
headless_jobs_.emplace_back(cookie);
callback_ = std::move(callback);

// There is no need for a weak pointer here since the mojo proxy is held
Expand All @@ -152,7 +154,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 +173,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 108d685

Please sign in to comment.