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