Add error logging to Windows print backend
Getting details about why some low-level print driver interactions might be failing to see if it can help triage the behavior. Bug: 1211621 Change-Id: I7e56ffa79abfa02784417475e2ebb651ef401e54 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2910387 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Alan Screen <awscreen@chromium.org> Cr-Commit-Position: refs/heads/master@{#885794}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
da6192a11f
commit
6ebd094bf4
@ -215,7 +215,12 @@ mojom::ResultCode PrintBackendWin::EnumeratePrinters(
|
||||
// No bytes needed could mean the operation failed or that there are simply
|
||||
// no printer drivers installed. Rely upon system error code to
|
||||
// distinguish between these.
|
||||
return GetResultCodeFromSystemErrorCode(logging::GetLastSystemErrorCode());
|
||||
logging::SystemErrorCode code = logging::GetLastSystemErrorCode();
|
||||
if (code != ERROR_SUCCESS) {
|
||||
LOG(ERROR) << "Error enumerating printers: "
|
||||
<< logging::SystemErrorCodeToString(code);
|
||||
}
|
||||
return GetResultCodeFromSystemErrorCode(code);
|
||||
}
|
||||
|
||||
auto printer_info_buffer = std::make_unique<BYTE[]>(bytes_needed);
|
||||
@ -244,12 +249,15 @@ mojom::ResultCode PrintBackendWin::EnumeratePrinters(
|
||||
std::string PrintBackendWin::GetDefaultPrinterName() {
|
||||
DWORD size = MAX_PATH;
|
||||
TCHAR default_printer_name[MAX_PATH];
|
||||
std::string ret;
|
||||
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
|
||||
base::BlockingType::MAY_BLOCK);
|
||||
if (::GetDefaultPrinter(default_printer_name, &size))
|
||||
ret = base::WideToUTF8(default_printer_name);
|
||||
return ret;
|
||||
if (!::GetDefaultPrinter(default_printer_name, &size)) {
|
||||
LOG(ERROR) << "Error getting default printer: "
|
||||
<< logging::SystemErrorCodeToString(
|
||||
logging::GetLastSystemErrorCode());
|
||||
return std::string();
|
||||
}
|
||||
return base::WideToUTF8(default_printer_name);
|
||||
}
|
||||
|
||||
mojom::ResultCode PrintBackendWin::GetPrinterBasicInfo(
|
||||
|
Reference in New Issue
Block a user