Skip to content

Commit

Permalink
fix: headless job tracking in printToPDF (#36046)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Oct 18, 2022
1 parent b13606e commit a8d89b3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 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 @@ -168,7 +171,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 a8d89b3

Please sign in to comment.