Skip to content

Commit

Permalink
chore: add logging for print_backend failures
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jun 24, 2021
1 parent 0f16575 commit 2ffdd11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion shell/browser/api/electron_api_printing.cc
Expand Up @@ -47,7 +47,10 @@ printing::PrinterList GetPrinterList() {
// TODO(deepak1556): Deprecate this api in favor of an
// async version and post a non blocing task call.
base::ThreadRestrictions::ScopedAllowIO allow_io;
print_backend->EnumeratePrinters(&printers);
printing::mojom::ResultCode code =
print_backend->EnumeratePrinters(&printers);
if (code != printing::mojom::ResultCode::kSuccess)
LOG(INFO) << "Failed to enumerate printers";
}
return printers;
}
Expand Down
11 changes: 9 additions & 2 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -435,14 +435,21 @@ std::u16string GetDefaultPrinterAsync() {
printing::PrintBackend::CreateInstance(
g_browser_process->GetApplicationLocale());
std::string printer_name;
print_backend->GetDefaultPrinterName(printer_name);
printing::mojom::ResultCode code =
print_backend->GetDefaultPrinterName(printer_name);
if (code != printing::mojom::ResultCode::kSuccess) {
LOG(INFO) << "Failed to get default printer name";
}

// Some devices won't have a default printer, so we should
// also check for existing printers and pick the first
// one should it exist.
if (printer_name.empty()) {
printing::PrinterList printers;
print_backend->EnumeratePrinters(&printers);
printing::mojom::ResultCode code =
print_backend->EnumeratePrinters(&printers);
if (code != printing::mojom::ResultCode::kSuccess)
LOG(INFO) << "Failed to enumerate printers";
if (!printers.empty())
printer_name = printers.front().printer_name;
}
Expand Down

0 comments on commit 2ffdd11

Please sign in to comment.