diff --git chrome/browser/printing/printer_query.cc chrome/browser/printing/printer_query.cc index 5786a450fdb6..2abaa6e3168e 100644 --- chrome/browser/printing/printer_query.cc +++ chrome/browser/printing/printer_query.cc @@ -12,6 +12,7 @@ #include "base/location.h" #include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/browser/printing/print_job_worker.h" #include "content/public/browser/browser_task_traits.h" @@ -22,7 +23,9 @@ namespace printing { PrinterQuery::PrinterQuery(int render_process_id, int render_frame_id) - : cookie_(PrintSettings::NewCookie()), + : base::RefCountedDeleteOnSequence( + base::ThreadTaskRunnerHandle::Get()), + cookie_(PrintSettings::NewCookie()), worker_(std::make_unique(render_process_id, render_frame_id, this)) { @@ -57,7 +60,7 @@ void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings, } std::unique_ptr PrinterQuery::DetachWorker() { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(!callback_); DCHECK(worker_); diff --git chrome/browser/printing/printer_query.h chrome/browser/printing/printer_query.h index 6d9b0e74196f..b6d8e2220d02 100644 --- chrome/browser/printing/printer_query.h +++ chrome/browser/printing/printer_query.h @@ -9,7 +9,7 @@ #include "base/callback.h" #include "base/macros.h" -#include "base/memory/ref_counted.h" +#include "base/memory/ref_counted_delete_on_sequence.h" #include "base/values.h" #include "printing/print_job_constants.h" #include "printing/print_settings.h" @@ -24,7 +24,7 @@ namespace printing { class PrintJobWorker; // Query the printer for settings. -class PrinterQuery : public base::RefCountedThreadSafe { +class PrinterQuery : public base::RefCountedDeleteOnSequence { public: // GetSettings() UI parameter. enum class GetSettingsAskParam { @@ -41,6 +41,8 @@ class PrinterQuery : public base::RefCountedThreadSafe { // Detach the PrintJobWorker associated to this object. Virtual so that tests // can override. + // Called on the UI thread. + // TODO(thestig): Do |worker_| and |callback_| need locks? virtual std::unique_ptr DetachWorker(); // Virtual so that tests can override. @@ -84,8 +86,9 @@ class PrinterQuery : public base::RefCountedThreadSafe { bool PostTask(const base::Location& from_here, base::OnceClosure task); protected: - // Refcounted class. - friend class base::RefCountedThreadSafe; + // RefCountedDeleteOnSequence class. + friend class base::RefCountedDeleteOnSequence; + friend class base::DeleteHelper; virtual ~PrinterQuery();