From 2ffdd11330a701e036fa6c43713a4d08ad07001c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 24 Jun 2021 19:16:59 +0200 Subject: [PATCH] chore: add logging for print_backend failures --- shell/browser/api/electron_api_printing.cc | 5 ++++- shell/browser/api/electron_api_web_contents.cc | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/shell/browser/api/electron_api_printing.cc b/shell/browser/api/electron_api_printing.cc index a73005f735793..6841aec62b3a6 100644 --- a/shell/browser/api/electron_api_printing.cc +++ b/shell/browser/api/electron_api_printing.cc @@ -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; } diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 5f11b2f5feda3..5e3a51fe5177d 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -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; }