OLD | NEW |
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 <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
15 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
16 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
18 #include "printing/print_destination_interface.h" | 17 #include "printing/print_destination_interface.h" |
19 | 18 |
20 namespace printing { | 19 namespace printing { |
21 | 20 |
22 class JobEventDetails; | 21 class JobEventDetails; |
23 class PrintJob; | 22 class PrintJob; |
24 class PrinterQuery; | 23 class PrinterQuery; |
25 | 24 |
26 class PrintQueriesQueue : public base::RefCountedThreadSafe<PrintQueriesQueue> { | 25 class PrintQueriesQueue : public base::RefCountedThreadSafe<PrintQueriesQueue> { |
27 public: | 26 public: |
28 PrintQueriesQueue(); | 27 PrintQueriesQueue(); |
29 | 28 |
30 // Sets the print destination to be set on the next print job. | 29 // Sets the print destination to be set on the next print job. |
31 void SetDestination(PrintDestinationInterface* destination); | 30 void SetDestination(PrintDestinationInterface* destination); |
32 | 31 |
33 // Queues a semi-initialized worker thread. Can be called from any thread. | 32 // Queues a semi-initialized worker thread. Can be called from any thread. |
34 // Current use case is queuing from the I/O thread. | 33 // Current use case is queuing from the I/O thread. |
35 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) | 34 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) |
36 void QueuePrinterQuery(PrinterQuery* job); | 35 void QueuePrinterQuery(PrinterQuery* job); |
37 | 36 |
38 // Pops a queued PrintJobWorkerOwner object that was previously queued or | 37 // Pops a queued PrintJobWorkerOwner object that was previously queued or |
39 // create new one. Can be called from any thread. | 38 // create new one. Can be called from any thread. |
40 scoped_refptr<PrinterQuery> PopPrinterQuery(int document_cookie); | 39 scoped_refptr<PrinterQuery> PopPrinterQuery(int document_cookie); |
41 | 40 |
42 // Creates new query. | 41 // Creates new query. |
43 scoped_refptr<PrinterQuery> CreatePrinterQuery(int render_process_id, | 42 scoped_refptr<PrinterQuery> CreatePrinterQuery(); |
44 int render_view_id); | |
45 | 43 |
46 void Shutdown(); | 44 void Shutdown(); |
47 | 45 |
48 private: | 46 private: |
49 friend class base::RefCountedThreadSafe<PrintQueriesQueue>; | 47 friend class base::RefCountedThreadSafe<PrintQueriesQueue>; |
50 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; | 48 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; |
51 | 49 |
52 virtual ~PrintQueriesQueue(); | 50 virtual ~PrintQueriesQueue(); |
53 | 51 |
54 // Used to serialize access to queued_workers_. | 52 // Used to serialize access to queued_workers_. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 scoped_refptr<PrintQueriesQueue> queue_; | 95 scoped_refptr<PrintQueriesQueue> queue_; |
98 | 96 |
99 bool is_shutdown_; | 97 bool is_shutdown_; |
100 | 98 |
101 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); | 99 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); |
102 }; | 100 }; |
103 | 101 |
104 } // namespace printing | 102 } // namespace printing |
105 | 103 |
106 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ | 104 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ |
OLD | NEW |