Commit feb597bb authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Log printer information in PrintJobWorker::UpdatePrintSettings().

PrintJobWorker::UpdatePrintSettings() is used for printing, but does not
log any information in case of a crash. Add a ScopedPrinterInfo here to
capture printer driver info for the duration of the call, so crashes in
this code path can give more clues as to what is causing the crashes.

Bug: 1013433
Change-Id: Ic6e1dab3cb40a70c408fb8a0a3c6d08601b24cb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855298
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705142}
parent 5750f040
...@@ -205,6 +205,7 @@ class ScopedIPCSupport; ...@@ -205,6 +205,7 @@ class ScopedIPCSupport;
} }
} }
namespace printing { namespace printing {
class PrintJobWorker;
class PrinterQuery; class PrinterQuery;
} }
namespace rlz_lib { namespace rlz_lib {
...@@ -352,6 +353,7 @@ class BASE_EXPORT ScopedAllowBlocking { ...@@ -352,6 +353,7 @@ class BASE_EXPORT ScopedAllowBlocking {
friend class memory_instrumentation::OSMetrics; friend class memory_instrumentation::OSMetrics;
friend class module_installer::ScopedAllowModulePakLoad; friend class module_installer::ScopedAllowModulePakLoad;
friend class mojo::CoreLibraryInitializer; friend class mojo::CoreLibraryInitializer;
friend class printing::PrintJobWorker;
friend class resource_coordinator::TabManagerDelegate; // crbug.com/778703 friend class resource_coordinator::TabManagerDelegate; // crbug.com/778703
friend class ui::MaterialDesignController; friend class ui::MaterialDesignController;
friend class web::WebSubThread; friend class web::WebSubThread;
......
...@@ -22,11 +22,13 @@ ...@@ -22,11 +22,13 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/crash/core/common/crash_keys.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "printing/backend/print_backend.h"
#include "printing/print_job_constants.h" #include "printing/print_job_constants.h"
#include "printing/printed_document.h" #include "printing/printed_document.h"
#include "printing/printing_utils.h" #include "printing/printing_utils.h"
...@@ -39,6 +41,7 @@ ...@@ -39,6 +41,7 @@
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/threading/thread_restrictions.h"
#include "printing/printed_page_win.h" #include "printing/printed_page_win.h"
#endif #endif
...@@ -203,6 +206,21 @@ void PrintJobWorker::SetSettingsFromPOD( ...@@ -203,6 +206,21 @@ void PrintJobWorker::SetSettingsFromPOD(
void PrintJobWorker::UpdatePrintSettings(base::Value new_settings, void PrintJobWorker::UpdatePrintSettings(base::Value new_settings,
SettingsCallback callback) { SettingsCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<crash_keys::ScopedPrinterInfo> crash_key;
if (new_settings.FindIntKey(kSettingPrinterType).value() == kLocalPrinter) {
#if defined(OS_WIN)
// Blocking is needed here because Windows printer drivers are oftentimes
// not thread-safe and have to be accessed on the UI thread.
base::ScopedAllowBlocking allow_blocking;
#endif
scoped_refptr<PrintBackend> print_backend =
PrintBackend::CreateInstance(nullptr);
std::string printer_name = *new_settings.FindStringKey(kSettingDeviceName);
crash_key = std::make_unique<crash_keys::ScopedPrinterInfo>(
print_backend->GetPrinterDriverInfo(printer_name));
}
PrintingContext::Result result = PrintingContext::Result result =
printing_context_->UpdatePrintSettings(std::move(new_settings)); printing_context_->UpdatePrintSettings(std::move(new_settings));
GetSettingsDone(std::move(callback), result); GetSettingsDone(std::move(callback), result);
......
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