Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/chromeos/printing/cups_print_job_manager_impl.h

Issue 2748253005: Cleanup jobs which have failed. (Closed)
Patch Set: fix fake Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 17 matching lines...) Expand all
28 std::vector<::printing::QueueStatus> queues; 28 std::vector<::printing::QueueStatus> queues;
29 }; 29 };
30 30
31 class CupsPrintJobManagerImpl : public CupsPrintJobManager, 31 class CupsPrintJobManagerImpl : public CupsPrintJobManager,
32 public content::NotificationObserver { 32 public content::NotificationObserver {
33 public: 33 public:
34 explicit CupsPrintJobManagerImpl(Profile* profile); 34 explicit CupsPrintJobManagerImpl(Profile* profile);
35 ~CupsPrintJobManagerImpl() override; 35 ~CupsPrintJobManagerImpl() override;
36 36
37 // CupsPrintJobManager overrides: 37 // CupsPrintJobManager overrides:
38 bool CancelPrintJob(CupsPrintJob* job) override; 38 void CancelPrintJob(CupsPrintJob* job) override;
39 bool SuspendPrintJob(CupsPrintJob* job) override; 39 bool SuspendPrintJob(CupsPrintJob* job) override;
40 bool ResumePrintJob(CupsPrintJob* job) override; 40 bool ResumePrintJob(CupsPrintJob* job) override;
41 41
42 // NotificationObserver overrides: 42 // NotificationObserver overrides:
43 void Observe(int type, 43 void Observe(int type,
44 const content::NotificationSource& source, 44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) override; 45 const content::NotificationDetails& details) override;
46 46
47 private: 47 private:
48 // Begin monitoring a print job for a given |printer_name| with the given 48 // Begin monitoring a print job for a given |printer_name| with the given
49 // |title| with the pages |total_page_number|. 49 // |title| with the pages |total_page_number|.
50 bool CreatePrintJob(const std::string& printer_name, 50 bool CreatePrintJob(const std::string& printer_name,
51 const std::string& title, 51 const std::string& title,
52 int job_id, 52 int job_id,
53 int total_page_number); 53 int total_page_number);
54 54
55 // Schedule a query of CUPS for print job status with the default delay. 55 // Schedule a query of CUPS for print job status with the default delay.
56 void ScheduleQuery(); 56 void ScheduleQuery();
57 // Schedule a query of CUPS for print job status with a delay of |delay|. 57 // Schedule a query of CUPS for print job status with a delay of |delay|.
58 void ScheduleQuery(const base::TimeDelta& delay); 58 void ScheduleQuery(const base::TimeDelta& delay);
59 59
60 // Schedule the CUPS query off the UI thread. Posts results back to UI thread 60 // Schedule the CUPS query off the UI thread. Posts results back to UI thread
61 // to UpdateJobs. 61 // to UpdateJobs.
62 void PostQuery(); 62 void PostQuery();
63 63
64 // Updates the state of a print job based on |printer_status| and |job|.
65 // Returns true if observers need to be notified of an update.
66 bool UpdatePrintJob(const ::printing::PrinterStatus& printer_status,
67 const ::printing::CupsJob& job,
68 CupsPrintJob* print_job);
69
64 // Process jobs from CUPS and perform notifications. 70 // Process jobs from CUPS and perform notifications.
65 void UpdateJobs(const QueryResult& results); 71 void UpdateJobs(const QueryResult& results);
66 72
67 // Mark remaining jobs as errors and remove active jobs. 73 // Mark remaining jobs as errors and remove active jobs.
68 void PurgeJobs(); 74 void PurgeJobs();
69 75
76 // Cancel the print job on the blocking thread.
77 void CancelJobImpl(const std::string& printer_id, const int job_id);
78
70 // Notify observers that a state update has occured for |job|. 79 // Notify observers that a state update has occured for |job|.
71 void NotifyJobStateUpdate(CupsPrintJob* job); 80 void NotifyJobStateUpdate(CupsPrintJob* job);
72 81
73 // Ongoing print jobs. 82 // Ongoing print jobs.
74 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_; 83 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_;
75 84
76 // Prevents multiple queries from being scheduled simultaneously. 85 // Prevents multiple queries from being scheduled simultaneously.
77 bool in_query_ = false; 86 bool in_query_ = false;
78 87
79 // Records the number of consecutive times the GetJobs query has failed. 88 // Records the number of consecutive times the GetJobs query has failed.
80 int retry_count_ = 0; 89 int retry_count_ = 0;
81 90
82 ::printing::CupsConnection cups_connection_; 91 ::printing::CupsConnection cups_connection_;
83 content::NotificationRegistrar registrar_; 92 content::NotificationRegistrar registrar_;
84 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; 93 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_;
85 94
86 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl); 95 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl);
87 }; 96 };
88 97
89 } // namespace chromeos 98 } // namespace chromeos
90 99
91 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ 100 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698