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

Side by Side Diff: chrome/browser/printing/print_job_manager.h

Issue 10808006: Move printing.* prefs from local state to profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased just in case as the CL is a few days old now plus I got my branches all mixed up a bit. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/browser/printing/print_job_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PRINTING_PRINT_JOB_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "chrome/browser/prefs/pref_member.h"
13 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
15 #include "printing/print_destination_interface.h" 14 #include "printing/print_destination_interface.h"
16 15
17 class PrefService;
18
19 namespace printing { 16 namespace printing {
20 17
21 class JobEventDetails; 18 class JobEventDetails;
22 class PrintJob; 19 class PrintJob;
23 class PrinterQuery; 20 class PrinterQuery;
24 21
25 class PrintJobManager : public content::NotificationObserver { 22 class PrintJobManager : public content::NotificationObserver {
26 public: 23 public:
27 PrintJobManager(); 24 PrintJobManager();
28 virtual ~PrintJobManager(); 25 virtual ~PrintJobManager();
29 26
30 // Registers for changes to the printing enabled preference in |prefs|.
31 // This method should be called on the UI thread.
32 void InitOnUIThread(PrefService* prefs);
33
34 // On browser quit, we should wait to have the print job finished. 27 // On browser quit, we should wait to have the print job finished.
35 void OnQuit(); 28 void OnQuit();
36 29
37 // Stops all printing jobs. If wait_for_finish is true, tries to give jobs 30 // Stops all printing jobs. If wait_for_finish is true, tries to give jobs
38 // a chance to complete before stopping them. 31 // a chance to complete before stopping them.
39 void StopJobs(bool wait_for_finish); 32 void StopJobs(bool wait_for_finish);
40 33
41 // Sets the print destination to be set on the next print job. 34 // Sets the print destination to be set on the next print job.
42 void SetPrintDestination(PrintDestinationInterface* destination); 35 void SetPrintDestination(PrintDestinationInterface* destination);
43 36
44 // Queues a semi-initialized worker thread. Can be called from any thread. 37 // Queues a semi-initialized worker thread. Can be called from any thread.
45 // Current use case is queuing from the I/O thread. 38 // Current use case is queuing from the I/O thread.
46 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) 39 // TODO(maruel): Have them vanish after a timeout (~5 minutes?)
47 void QueuePrinterQuery(PrinterQuery* job); 40 void QueuePrinterQuery(PrinterQuery* job);
48 41
49 // Pops a queued PrintJobWorkerOwner object that was previously queued. Can be 42 // Pops a queued PrintJobWorkerOwner object that was previously queued. Can be
50 // called from any thread. Current use case is poping from the browser thread. 43 // called from any thread. Current use case is poping from the browser thread.
51 void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job); 44 void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job);
52 45
53 static void RegisterPrefs(PrefService* prefs);
54
55 // content::NotificationObserver 46 // content::NotificationObserver
56 virtual void Observe(int type, 47 virtual void Observe(int type,
57 const content::NotificationSource& source, 48 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE; 49 const content::NotificationDetails& details) OVERRIDE;
59 50
60 // Only accessed on the IO thread. UI thread can query
61 // prefs::kPrintingEnabled via g_browser_process->local_state() directly.
62 bool printing_enabled() const;
63
64 // May return NULL when no destination was set. 51 // May return NULL when no destination was set.
65 PrintDestinationInterface* destination() const { return destination_.get(); } 52 PrintDestinationInterface* destination() const { return destination_.get(); }
66 53
67 private: 54 private:
68 typedef std::vector<scoped_refptr<PrintJob> > PrintJobs; 55 typedef std::vector<scoped_refptr<PrintJob> > PrintJobs;
69 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; 56 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries;
70 57
71 // Processes a NOTIFY_PRINT_JOB_EVENT notification. 58 // Processes a NOTIFY_PRINT_JOB_EVENT notification.
72 void OnPrintJobEvent(PrintJob* print_job, 59 void OnPrintJobEvent(PrintJob* print_job,
73 const JobEventDetails& event_details); 60 const JobEventDetails& event_details);
74 61
75 content::NotificationRegistrar registrar_; 62 content::NotificationRegistrar registrar_;
76 63
77 // Printing is enabled/disabled. For printing with the native print dialog,
78 // this variable is checked at only one place, by
79 // PrintingMessageFilter::OnGetDefaultPrintSettings. If its value is true
80 // at that point, then the initiated print flow will complete itself,
81 // even if the value of this variable changes afterwards.
82 // In the print preview workflow, this variable is checked in
83 // PrintingMessageFilter::OnUpdatePrintSettings, which gets called multiple
84 // times in the print preview workflow.
85 BooleanPrefMember printing_enabled_;
86
87 // Used to serialize access to queued_workers_. 64 // Used to serialize access to queued_workers_.
88 base::Lock lock_; 65 base::Lock lock_;
89 66
90 PrinterQueries queued_queries_; 67 PrinterQueries queued_queries_;
91 68
92 scoped_refptr<PrintDestinationInterface> destination_; 69 scoped_refptr<PrintDestinationInterface> destination_;
93 70
94 // Current print jobs that are active. 71 // Current print jobs that are active.
95 PrintJobs current_jobs_; 72 PrintJobs current_jobs_;
96 73
97 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); 74 DISALLOW_COPY_AND_ASSIGN(PrintJobManager);
98 }; 75 };
99 76
100 } // namespace printing 77 } // namespace printing
101 78
102 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ 79 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/browser/printing/print_job_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698