| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 // NotificationObserver overrides: | 37 // NotificationObserver overrides: |
| 38 void Observe(int type, | 38 void Observe(int type, |
| 39 const content::NotificationSource& source, | 39 const content::NotificationSource& source, |
| 40 const content::NotificationDetails& details) override; | 40 const content::NotificationDetails& details) override; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // Begin monitoring a print job for a given |printer_name| with the given | 43 // Begin monitoring a print job for a given |printer_name| with the given |
| 44 // |title| with the pages |total_page_number|. | 44 // |title| with the pages |total_page_number|. |
| 45 bool CreatePrintJob(const std::string& printer_name, | 45 bool CreatePrintJob(const std::string& printer_name, |
| 46 const std::string& title, | 46 const std::string& title, |
| 47 int job_id, |
| 47 int total_page_number); | 48 int total_page_number); |
| 48 | 49 |
| 49 // Schedule a query of CUPS for print job status. | 50 // Schedule a query of CUPS for print job status with the default delay. |
| 50 void ScheduleQuery(); | 51 void ScheduleQuery(); |
| 52 // Schedule a query of CUPS for print job status with a delay of |delay|. |
| 53 void ScheduleQuery(const base::TimeDelta& delay); |
| 51 | 54 |
| 52 // Query CUPS for print job status. | 55 // Query CUPS for print job status. |
| 53 void QueryCups(); | 56 void QueryCups(); |
| 54 | 57 |
| 55 // Process jobs from CUPS and perform notifications. | 58 // Process jobs from CUPS and perform notifications. |
| 56 void UpdateJobs(const std::vector<::printing::CupsJob>& jobs); | 59 void UpdateJobs(const std::vector<::printing::CupsJob>& jobs); |
| 57 | 60 |
| 58 // Updates the state and performs the appropriate notifications. | 61 // Updates the state and performs the appropriate notifications. |
| 59 void JobStateUpdated(CupsPrintJob* job, CupsPrintJob::State new_state); | 62 void JobStateUpdated(CupsPrintJob* job, CupsPrintJob::State new_state); |
| 60 | 63 |
| 61 // Ongoing print jobs. | 64 // Ongoing print jobs. |
| 62 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_; | 65 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_; |
| 63 | 66 |
| 67 // Prevents multiple queries from being scheduled simultaneously. |
| 68 bool in_query_ = false; |
| 69 |
| 64 ::printing::CupsConnection cups_connection_; | 70 ::printing::CupsConnection cups_connection_; |
| 65 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
| 66 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; | 72 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; |
| 67 | 73 |
| 68 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl); | 74 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl); |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 } // namespace chromeos | 77 } // namespace chromeos |
| 72 | 78 |
| 73 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ |
| OLD | NEW |