| 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_WORKER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "printing/page_number.h" | 13 #include "printing/page_number.h" |
| 14 #include "printing/print_destination_interface.h" | |
| 15 #include "printing/print_job_constants.h" | 14 #include "printing/print_job_constants.h" |
| 16 #include "printing/printing_context.h" | 15 #include "printing/printing_context.h" |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class DictionaryValue; | 18 class DictionaryValue; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace printing { | 21 namespace printing { |
| 23 | 22 |
| 24 class PrintJob; | 23 class PrintJob; |
| 25 class PrintJobWorkerOwner; | 24 class PrintJobWorkerOwner; |
| 26 class PrintedDocument; | 25 class PrintedDocument; |
| 27 class PrintedPage; | 26 class PrintedPage; |
| 28 | 27 |
| 29 // Worker thread code. It manages the PrintingContext, which can be blocking | 28 // Worker thread code. It manages the PrintingContext, which can be blocking |
| 30 // and/or run a message loop. This is the object that generates most | 29 // and/or run a message loop. This is the object that generates most |
| 31 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a | 30 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a |
| 32 // NotificationTask task to be executed from the right thread, the UI thread. | 31 // NotificationTask task to be executed from the right thread, the UI thread. |
| 33 // PrintJob always outlives its worker instance. | 32 // PrintJob always outlives its worker instance. |
| 34 class PrintJobWorker { | 33 class PrintJobWorker { |
| 35 public: | 34 public: |
| 36 PrintJobWorker(int render_process_id, | 35 PrintJobWorker(int render_process_id, |
| 37 int render_view_id, | 36 int render_view_id, |
| 38 PrintJobWorkerOwner* owner); | 37 PrintJobWorkerOwner* owner); |
| 39 virtual ~PrintJobWorker(); | 38 virtual ~PrintJobWorker(); |
| 40 | 39 |
| 41 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 40 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
| 42 | 41 |
| 43 // Set a destination for print. | |
| 44 // This supersedes the document's rendering destination. | |
| 45 void SetPrintDestination(PrintDestinationInterface* destination); | |
| 46 | |
| 47 // Initializes the print settings. If |ask_user_for_settings| is true, a | 42 // Initializes the print settings. If |ask_user_for_settings| is true, a |
| 48 // Print... dialog box will be shown to ask the user his preference. | 43 // Print... dialog box will be shown to ask the user his preference. |
| 49 void GetSettings( | 44 void GetSettings( |
| 50 bool ask_user_for_settings, | 45 bool ask_user_for_settings, |
| 51 int document_page_count, | 46 int document_page_count, |
| 52 bool has_selection, | 47 bool has_selection, |
| 53 MarginType margin_type); | 48 MarginType margin_type); |
| 54 | 49 |
| 55 // Set the new print settings. | 50 // Set the new print settings. |
| 56 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); | 51 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 128 |
| 134 // Printing context delegate. | 129 // Printing context delegate. |
| 135 scoped_ptr<PrintingContext::Delegate> printing_context_delegate_; | 130 scoped_ptr<PrintingContext::Delegate> printing_context_delegate_; |
| 136 | 131 |
| 137 // Information about the printer setting. | 132 // Information about the printer setting. |
| 138 scoped_ptr<PrintingContext> printing_context_; | 133 scoped_ptr<PrintingContext> printing_context_; |
| 139 | 134 |
| 140 // The printed document. Only has read-only access. | 135 // The printed document. Only has read-only access. |
| 141 scoped_refptr<PrintedDocument> document_; | 136 scoped_refptr<PrintedDocument> document_; |
| 142 | 137 |
| 143 // The print destination, may be NULL. | |
| 144 scoped_refptr<PrintDestinationInterface> destination_; | |
| 145 | |
| 146 // The print job owning this worker thread. It is guaranteed to outlive this | 138 // The print job owning this worker thread. It is guaranteed to outlive this |
| 147 // object. | 139 // object. |
| 148 PrintJobWorkerOwner* owner_; | 140 PrintJobWorkerOwner* owner_; |
| 149 | 141 |
| 150 // Current page number to print. | 142 // Current page number to print. |
| 151 PageNumber page_number_; | 143 PageNumber page_number_; |
| 152 | 144 |
| 153 // Thread to run worker tasks. | 145 // Thread to run worker tasks. |
| 154 base::Thread thread_; | 146 base::Thread thread_; |
| 155 | 147 |
| 156 // Tread-safe pointer to task runner of the |thread_|. | 148 // Tread-safe pointer to task runner of the |thread_|. |
| 157 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 149 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 158 | 150 |
| 159 // Used to generate a WeakPtr for callbacks. | 151 // Used to generate a WeakPtr for callbacks. |
| 160 base::WeakPtrFactory<PrintJobWorker> weak_factory_; | 152 base::WeakPtrFactory<PrintJobWorker> weak_factory_; |
| 161 | 153 |
| 162 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); | 154 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); |
| 163 }; | 155 }; |
| 164 | 156 |
| 165 } // namespace printing | 157 } // namespace printing |
| 166 | 158 |
| 167 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ | 159 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
| OLD | NEW |