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

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

Issue 2943843002: Convert to CupsPrintJobManagerImpl to TaskScheduler. (Closed)
Patch Set: notification must happen on the browser thread Created 3 years, 6 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>
11 #include <unordered_map> 11 #include <unordered_map>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/sequenced_task_runner.h"
17 #include "base/single_thread_task_runner.h"
15 #include "chrome/browser/chromeos/printing/cups_print_job.h" 18 #include "chrome/browser/chromeos/printing/cups_print_job.h"
16 #include "chrome/browser/chromeos/printing/cups_print_job_manager.h" 19 #include "chrome/browser/chromeos/printing/cups_print_job_manager.h"
17 #include "chrome/browser/chromeos/printing/printers_manager.h" 20 #include "chrome/browser/chromeos/printing/printers_manager.h"
18 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
20 #include "printing/backend/cups_connection.h" 23 #include "printing/backend/cups_connection.h"
21 24
22 class Profile; 25 class Profile;
23 26
24 namespace chromeos { 27 namespace chromeos {
25 28
26 struct QueryResult { 29 struct QueryResult {
27 QueryResult(); 30 QueryResult();
28 QueryResult(const QueryResult& other); 31 QueryResult(const QueryResult& other);
29 ~QueryResult(); 32 ~QueryResult();
30 33
31 bool success; 34 bool success;
32 std::vector<::printing::QueueStatus> queues; 35 std::vector<::printing::QueueStatus> queues;
33 }; 36 };
34 37
35 class CupsPrintJobManagerImpl : public CupsPrintJobManager, 38 class CupsPrintJobManagerImpl : public CupsPrintJobManager,
36 public content::NotificationObserver { 39 public content::NotificationObserver {
37 public: 40 public:
38 explicit CupsPrintJobManagerImpl(Profile* profile); 41 CupsPrintJobManagerImpl(
42 Profile* profile,
43 scoped_refptr<base::SingleThreadTaskRunner> browser_thread_runner);
39 ~CupsPrintJobManagerImpl() override; 44 ~CupsPrintJobManagerImpl() override;
40 45
41 // CupsPrintJobManager overrides: 46 // CupsPrintJobManager overrides:
42 void CancelPrintJob(CupsPrintJob* job) override; 47 void CancelPrintJob(CupsPrintJob* job) override;
43 bool SuspendPrintJob(CupsPrintJob* job) override; 48 bool SuspendPrintJob(CupsPrintJob* job) override;
44 bool ResumePrintJob(CupsPrintJob* job) override; 49 bool ResumePrintJob(CupsPrintJob* job) override;
45 50
46 // NotificationObserver overrides: 51 // NotificationObserver overrides:
47 void Observe(int type, 52 void Observe(int type,
48 const content::NotificationSource& source, 53 const content::NotificationSource& source,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_; 92 std::map<std::string, std::unique_ptr<CupsPrintJob>> jobs_;
88 93
89 // Prevents multiple queries from being scheduled simultaneously. 94 // Prevents multiple queries from being scheduled simultaneously.
90 bool in_query_ = false; 95 bool in_query_ = false;
91 96
92 // Records the number of consecutive times the GetJobs query has failed. 97 // Records the number of consecutive times the GetJobs query has failed.
93 int retry_count_ = 0; 98 int retry_count_ = 0;
94 99
95 ::printing::CupsConnection cups_connection_; 100 ::printing::CupsConnection cups_connection_;
96 content::NotificationRegistrar registrar_; 101 content::NotificationRegistrar registrar_;
102 scoped_refptr<base::SingleThreadTaskRunner> browser_thread_runner_;
103 scoped_refptr<base::SequencedTaskRunner> query_runner_;
97 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; 104 base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_;
98 105
99 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl); 106 DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl);
100 }; 107 };
101 108
102 } // namespace chromeos 109 } // namespace chromeos
103 110
104 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_ 111 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698