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

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

Issue 10483006: Print support for Windows Metro... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self CR changes 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
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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "chrome/browser/prefs/pref_member.h" 13 #include "chrome/browser/prefs/pref_member.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "printing/print_destination_interface.h"
16 17
17 class PrefService; 18 class PrefService;
18 19
19 namespace printing { 20 namespace printing {
20 21
21 class JobEventDetails; 22 class JobEventDetails;
22 class PrintJob; 23 class PrintJob;
23 class PrinterQuery; 24 class PrinterQuery;
24 25
25 class PrintJobManager : public content::NotificationObserver { 26 class PrintJobManager : public content::NotificationObserver {
26 public: 27 public:
27 PrintJobManager(); 28 PrintJobManager();
28 virtual ~PrintJobManager(); 29 virtual ~PrintJobManager();
29 30
30 // Registers for changes to the printing enabled preference in |prefs|. 31 // Registers for changes to the printing enabled preference in |prefs|.
31 // This method should be called on the UI thread. 32 // This method should be called on the UI thread.
32 void InitOnUIThread(PrefService* prefs); 33 void InitOnUIThread(PrefService* prefs);
33 34
34 // On browser quit, we should wait to have the print job finished. 35 // On browser quit, we should wait to have the print job finished.
35 void OnQuit(); 36 void OnQuit();
36 37
37 // Stops all printing jobs. If wait_for_finish is true, tries to give jobs 38 // Stops all printing jobs. If wait_for_finish is true, tries to give jobs
38 // a chance to complete before stopping them. 39 // a chance to complete before stopping them.
39 void StopJobs(bool wait_for_finish); 40 void StopJobs(bool wait_for_finish);
40 41
42 // Sets the print destination to be set on the next print job. The value is
43 // automatically reset to NULL when the JOB_DONE event is received.
robertshield 2012/06/28 17:48:54 The last sentence describes implementation, not in
MAD 2012/06/28 19:05:51 Good point, I thought the caller might need to kno
44 void SetPrintDestination(PrintDestinationInterface* destination);
45
41 // Queues a semi-initialized worker thread. Can be called from any thread. 46 // Queues a semi-initialized worker thread. Can be called from any thread.
42 // Current use case is queuing from the I/O thread. 47 // Current use case is queuing from the I/O thread.
43 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) 48 // TODO(maruel): Have them vanish after a timeout (~5 minutes?)
44 void QueuePrinterQuery(PrinterQuery* job); 49 void QueuePrinterQuery(PrinterQuery* job);
45 50
46 // Pops a queued PrintJobWorkerOwner object that was previously queued. Can be 51 // Pops a queued PrintJobWorkerOwner object that was previously queued. Can be
47 // called from any thread. Current use case is poping from the browser thread. 52 // called from any thread. Current use case is poping from the browser thread.
48 void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job); 53 void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job);
49 54
50 static void RegisterPrefs(PrefService* prefs); 55 static void RegisterPrefs(PrefService* prefs);
51 56
52 // content::NotificationObserver 57 // content::NotificationObserver
53 virtual void Observe(int type, 58 virtual void Observe(int type,
54 const content::NotificationSource& source, 59 const content::NotificationSource& source,
55 const content::NotificationDetails& details) OVERRIDE; 60 const content::NotificationDetails& details) OVERRIDE;
56 61
57 // Only accessed on the IO thread. UI thread can query 62 // Only accessed on the IO thread. UI thread can query
58 // prefs::kPrintingEnabled via g_browser_process->local_state() directly. 63 // prefs::kPrintingEnabled via g_browser_process->local_state() directly.
59 bool printing_enabled() const; 64 bool printing_enabled() const;
60 65
66 PrintDestinationInterface* destination() const { return destination_.get(); }
robertshield 2012/06/28 17:48:54 Mention here that this may return NULL.
MAD 2012/06/28 19:05:51 Done.
67
61 private: 68 private:
62 typedef std::vector<scoped_refptr<PrintJob> > PrintJobs; 69 typedef std::vector<scoped_refptr<PrintJob> > PrintJobs;
63 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; 70 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries;
64 71
65 // Processes a NOTIFY_PRINT_JOB_EVENT notification. 72 // Processes a NOTIFY_PRINT_JOB_EVENT notification.
66 void OnPrintJobEvent(PrintJob* print_job, 73 void OnPrintJobEvent(PrintJob* print_job,
67 const JobEventDetails& event_details); 74 const JobEventDetails& event_details);
68 75
69 content::NotificationRegistrar registrar_; 76 content::NotificationRegistrar registrar_;
70 77
71 // Printing is enabled/disabled. For printing with the native print dialog, 78 // Printing is enabled/disabled. For printing with the native print dialog,
72 // this variable is checked at only one place, by 79 // this variable is checked at only one place, by
73 // PrintingMessageFilter::OnGetDefaultPrintSettings. If its value is true 80 // PrintingMessageFilter::OnGetDefaultPrintSettings. If its value is true
74 // at that point, then the initiated print flow will complete itself, 81 // at that point, then the initiated print flow will complete itself,
75 // even if the value of this variable changes afterwards. 82 // even if the value of this variable changes afterwards.
76 // In the print preview workflow, this variable is checked in 83 // In the print preview workflow, this variable is checked in
77 // PrintingMessageFilter::OnUpdatePrintSettings, which gets called multiple 84 // PrintingMessageFilter::OnUpdatePrintSettings, which gets called multiple
78 // times in the print preview workflow. 85 // times in the print preview workflow.
79 BooleanPrefMember printing_enabled_; 86 BooleanPrefMember printing_enabled_;
80 87
81 // Used to serialize access to queued_workers_. 88 // Used to serialize access to queued_workers_.
82 base::Lock lock_; 89 base::Lock lock_;
83 90
84 PrinterQueries queued_queries_; 91 PrinterQueries queued_queries_;
85 92
93 scoped_refptr<PrintDestinationInterface> destination_;
94
86 // Current print jobs that are active. 95 // Current print jobs that are active.
87 PrintJobs current_jobs_; 96 PrintJobs current_jobs_;
88 97
89 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); 98 DISALLOW_COPY_AND_ASSIGN(PrintJobManager);
90 }; 99 };
91 100
92 } // namespace printing 101 } // namespace printing
93 102
94 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ 103 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698