| 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/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #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. | |
| 31 void SetDestination(PrintDestinationInterface* destination); | |
| 32 | |
| 33 // Queues a semi-initialized worker thread. Can be called from any thread. | 29 // Queues a semi-initialized worker thread. Can be called from any thread. |
| 34 // Current use case is queuing from the I/O thread. | 30 // Current use case is queuing from the I/O thread. |
| 35 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) | 31 // TODO(maruel): Have them vanish after a timeout (~5 minutes?) |
| 36 void QueuePrinterQuery(PrinterQuery* job); | 32 void QueuePrinterQuery(PrinterQuery* job); |
| 37 | 33 |
| 38 // Pops a queued PrintJobWorkerOwner object that was previously queued or | 34 // Pops a queued PrintJobWorkerOwner object that was previously queued or |
| 39 // create new one. Can be called from any thread. | 35 // create new one. Can be called from any thread. |
| 40 scoped_refptr<PrinterQuery> PopPrinterQuery(int document_cookie); | 36 scoped_refptr<PrinterQuery> PopPrinterQuery(int document_cookie); |
| 41 | 37 |
| 42 // Creates new query. | 38 // Creates new query. |
| 43 scoped_refptr<PrinterQuery> CreatePrinterQuery(int render_process_id, | 39 scoped_refptr<PrinterQuery> CreatePrinterQuery(int render_process_id, |
| 44 int render_view_id); | 40 int render_view_id); |
| 45 | 41 |
| 46 void Shutdown(); | 42 void Shutdown(); |
| 47 | 43 |
| 48 private: | 44 private: |
| 49 friend class base::RefCountedThreadSafe<PrintQueriesQueue>; | 45 friend class base::RefCountedThreadSafe<PrintQueriesQueue>; |
| 50 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; | 46 typedef std::vector<scoped_refptr<PrinterQuery> > PrinterQueries; |
| 51 | 47 |
| 52 virtual ~PrintQueriesQueue(); | 48 virtual ~PrintQueriesQueue(); |
| 53 | 49 |
| 54 // Used to serialize access to queued_workers_. | 50 // Used to serialize access to queued_workers_. |
| 55 base::Lock lock_; | 51 base::Lock lock_; |
| 56 | 52 |
| 57 PrinterQueries queued_queries_; | 53 PrinterQueries queued_queries_; |
| 58 | 54 |
| 59 scoped_refptr<PrintDestinationInterface> destination_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(PrintQueriesQueue); | 55 DISALLOW_COPY_AND_ASSIGN(PrintQueriesQueue); |
| 62 }; | 56 }; |
| 63 | 57 |
| 64 class PrintJobManager : public content::NotificationObserver { | 58 class PrintJobManager : public content::NotificationObserver { |
| 65 public: | 59 public: |
| 66 PrintJobManager(); | 60 PrintJobManager(); |
| 67 virtual ~PrintJobManager(); | 61 virtual ~PrintJobManager(); |
| 68 | 62 |
| 69 // On browser quit, we should wait to have the print job finished. | 63 // On browser quit, we should wait to have the print job finished. |
| 70 void Shutdown(); | 64 void Shutdown(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 97 scoped_refptr<PrintQueriesQueue> queue_; | 91 scoped_refptr<PrintQueriesQueue> queue_; |
| 98 | 92 |
| 99 bool is_shutdown_; | 93 bool is_shutdown_; |
| 100 | 94 |
| 101 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); | 95 DISALLOW_COPY_AND_ASSIGN(PrintJobManager); |
| 102 }; | 96 }; |
| 103 | 97 |
| 104 } // namespace printing | 98 } // namespace printing |
| 105 | 99 |
| 106 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ | 100 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_MANAGER_H_ |
| OLD | NEW |