Chromium Code Reviews| Index: chrome/browser/chromeos/printing/cups_print_job_manager_impl.h |
| diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h |
| index afd64c901063fbc04acce7ef4e7731903616b7f5..bd9497f1abe962ffa8b938fa1f3b8e43ef18bc67 100644 |
| --- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h |
| +++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h |
| @@ -12,6 +12,7 @@ |
| #include <vector> |
| #include "base/memory/weak_ptr.h" |
| +#include "base/synchronization/lock.h" |
|
Lei Zhang
2017/03/07 23:31:29
nit: Not needed here?
skau
2017/03/10 01:07:00
Done.
|
| #include "chrome/browser/chromeos/printing/cups_print_job.h" |
| #include "chrome/browser/chromeos/printing/cups_print_job_manager.h" |
| #include "chrome/browser/chromeos/printing/printers_manager.h" |
| @@ -23,6 +24,11 @@ class Profile; |
| namespace chromeos { |
| +struct QueryResult { |
| + bool success; |
| + std::vector<::printing::QueueStatus> queues; |
| +}; |
| + |
| class CupsPrintJobManagerImpl : public CupsPrintJobManager, |
| public content::NotificationObserver { |
| public: |
| @@ -52,11 +58,14 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager, |
| // Schedule a query of CUPS for print job status with a delay of |delay|. |
| void ScheduleQuery(const base::TimeDelta& delay); |
| - // Query CUPS for print job status. |
| - void QueryCups(); |
| + // Schedule the CUPS query off the UI thread. |
| + void PostQuery(); |
| // Process jobs from CUPS and perform notifications. |
| - void UpdateJobs(const std::vector<::printing::CupsJob>& jobs); |
| + void UpdateJobs(const QueryResult& results); |
| + |
| + // Mark remaining jobs as errors and remove active jobs. |
| + void PurgeJobs(); |
| // Updates the state and performs the appropriate notifications. |
| void JobStateUpdated(CupsPrintJob* job, CupsPrintJob::State new_state); |
| @@ -67,6 +76,9 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager, |
| // Prevents multiple queries from being scheduled simultaneously. |
| bool in_query_ = false; |
| + // Records the number of consecutive times the GetJobs query has failed. |
| + int retry_count_ = 0; |
| + |
| ::printing::CupsConnection cups_connection_; |
| content::NotificationRegistrar registrar_; |
| base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; |