Fix build break
[chromium-blink-merge.git] / chrome / browser / printing / print_job_manager.h
blob749c29b49d6db2dfba9da2c6ea1ba70fdf570a3a
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_
8 #include <set>
9 #include <vector>
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "printing/print_destination_interface.h"
17 namespace printing {
19 class JobEventDetails;
20 class PrintJob;
21 class PrinterQuery;
23 class PrintJobManager : public content::NotificationObserver {
24 public:
25 PrintJobManager();
26 virtual ~PrintJobManager();
28 // On browser quit, we should wait to have the print job finished.
29 void OnQuit();
31 // Stops all printing jobs. If wait_for_finish is true, tries to give jobs
32 // a chance to complete before stopping them.
33 void StopJobs(bool wait_for_finish);
35 // Sets the print destination to be set on the next print job.
36 void SetPrintDestination(PrintDestinationInterface* destination);
38 // Queues a semi-initialized worker thread. Can be called from any thread.
39 // Current use case is queuing from the I/O thread.
40 // TODO(maruel): Have them vanish after a timeout (~5 minutes?)
41 void QueuePrinterQuery(PrinterQuery* job);
43 // Pops a queued PrintJobWorkerOwner object that was previously queued. Can be
44 // called from any thread. Current use case is poping from the browser thread.
45 void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job);
47 // content::NotificationObserver
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
52 // May return NULL when no destination was set.
53 PrintDestinationInterface* destination() const { return destination_.get(); }
55 private:
56 typedef std::set<scoped_refptr<PrintJob> > PrintJobs;
57 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries;
59 // Processes a NOTIFY_PRINT_JOB_EVENT notification.
60 void OnPrintJobEvent(PrintJob* print_job,
61 const JobEventDetails& event_details);
63 content::NotificationRegistrar registrar_;
65 // Used to serialize access to queued_workers_.
66 base::Lock lock_;
68 PrinterQueries queued_queries_;
70 scoped_refptr<PrintDestinationInterface> destination_;
72 // Current print jobs that are active.
73 PrintJobs current_jobs_;
75 DISALLOW_COPY_AND_ASSIGN(PrintJobManager);
78 } // namespace printing
80 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_