Commit a9a688a1 authored by Gavin Williams's avatar Gavin Williams Committed by Chromium LUCI CQ

scanning: Capture scan success status during PDF save

Currently when a scan completes a PDF is created without checking if the
scan was successful.

This change checks to see if scan fails before attempting to create the
PDF. Also |save_failed_| will be set when the PDF creation fails.

Bug: 1059779
Change-Id: I84bf426e33da6840c13cce3195bfaa111ff7c6dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612053Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841128}
parent 90b26928
......@@ -407,13 +407,12 @@ void ScanService::OnPageReceived(const base::FilePath& scan_to_path,
}
void ScanService::OnScanCompleted(bool success) {
if (!scanned_images_.empty()) {
if (success && !scanned_images_.empty()) {
base::PostTaskAndReplyWithResult(
task_runner_.get(), FROM_HERE,
base::BindOnce(&SaveAsPdf, scanned_images_, last_scanned_file_path_),
base::BindOnce(&ScanService::OnAllPagesSaved,
base::BindOnce(&ScanService::OnPdfSaved,
weak_ptr_factory_.GetWeakPtr()));
return;
}
// Post a task to the task runner to ensure all the pages have been saved
......@@ -431,6 +430,10 @@ void ScanService::OnCancelCompleted(bool success) {
scan_job_observer_->OnCancelComplete(success);
}
void ScanService::OnPdfSaved(const bool success) {
save_failed_ = !success;
}
void ScanService::OnPageSaved(const base::FilePath& saved_file_path) {
save_failed_ = save_failed_ || saved_file_path.empty();
last_scanned_file_path_ = save_failed_ ? base::FilePath() : saved_file_path;
......
......@@ -100,6 +100,9 @@ class ScanService : public scanning::mojom::ScanService, public KeyedService {
// LorgnetteScannerManager::CancelScan().
void OnCancelCompleted(bool success);
// Called once the task runner finishes saving a PDF file.
void OnPdfSaved(const bool success);
// Called once the task runner finishes saving a page of a scan.
void OnPageSaved(const base::FilePath& saved_file_path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment