OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "printing/page_number.h" | 13 #include "printing/page_number.h" |
| 14 #include "printing/print_destination_interface.h" |
14 #include "printing/printing_context.h" | 15 #include "printing/printing_context.h" |
15 #include "printing/print_job_constants.h" | 16 #include "printing/print_job_constants.h" |
16 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 } | 21 } |
21 | 22 |
22 namespace printing { | 23 namespace printing { |
23 | 24 |
24 class PrintedDocument; | 25 class PrintedDocument; |
25 class PrintedPage; | 26 class PrintedPage; |
26 class PrintJob; | 27 class PrintJob; |
27 class PrintJobWorkerOwner; | 28 class PrintJobWorkerOwner; |
28 | 29 |
29 // Worker thread code. All this code, except for the constructor, is executed in | 30 // Worker thread code. All this code, except for the constructor, is executed in |
30 // the worker thread. It manages the PrintingContext, which can be blocking | 31 // the worker thread. It manages the PrintingContext, which can be blocking |
31 // and/or run a message loop. This is the object that generates most | 32 // and/or run a message loop. This is the object that generates most |
32 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a | 33 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a |
33 // NotificationTask task to be executed from the right thread, the UI thread. | 34 // NotificationTask task to be executed from the right thread, the UI thread. |
34 // PrintJob always outlives its worker instance. | 35 // PrintJob always outlives its worker instance. |
35 class PrintJobWorker : public base::Thread { | 36 class PrintJobWorker : public base::Thread { |
36 public: | 37 public: |
37 explicit PrintJobWorker(PrintJobWorkerOwner* owner); | 38 explicit PrintJobWorker(PrintJobWorkerOwner* owner); |
38 virtual ~PrintJobWorker(); | 39 virtual ~PrintJobWorker(); |
39 | 40 |
40 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 41 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
41 | 42 |
| 43 // Set a destination for print. |
| 44 // This supercedes the document's rendering destination. |
| 45 void SetPrintDestination(PrintDestinationInterface* destination); |
| 46 |
42 // Initializes the print settings. If |ask_user_for_settings| is true, a | 47 // Initializes the print settings. If |ask_user_for_settings| is true, a |
43 // Print... dialog box will be shown to ask the user his preference. | 48 // Print... dialog box will be shown to ask the user his preference. |
44 void GetSettings(bool ask_user_for_settings, | 49 void GetSettings(bool ask_user_for_settings, |
45 gfx::NativeView parent_view, | 50 gfx::NativeView parent_view, |
46 int document_page_count, | 51 int document_page_count, |
47 bool has_selection, | 52 bool has_selection, |
48 MarginType margin_type); | 53 MarginType margin_type); |
49 | 54 |
50 // Set the new print settings. This function takes ownership of | 55 // Set the new print settings. This function takes ownership of |
51 // |new_settings|. | 56 // |new_settings|. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // displaying a dialog. So this needs to happen from the UI thread on these | 116 // displaying a dialog. So this needs to happen from the UI thread on these |
112 // systems. | 117 // systems. |
113 void UseDefaultSettings(); | 118 void UseDefaultSettings(); |
114 | 119 |
115 // Information about the printer setting. | 120 // Information about the printer setting. |
116 scoped_ptr<PrintingContext> printing_context_; | 121 scoped_ptr<PrintingContext> printing_context_; |
117 | 122 |
118 // The printed document. Only has read-only access. | 123 // The printed document. Only has read-only access. |
119 scoped_refptr<PrintedDocument> document_; | 124 scoped_refptr<PrintedDocument> document_; |
120 | 125 |
| 126 // The print destination, may be NULL. |
| 127 scoped_refptr<PrintDestinationInterface> destination_; |
| 128 |
121 // The print job owning this worker thread. It is guaranteed to outlive this | 129 // The print job owning this worker thread. It is guaranteed to outlive this |
122 // object. | 130 // object. |
123 PrintJobWorkerOwner* owner_; | 131 PrintJobWorkerOwner* owner_; |
124 | 132 |
125 // Current page number to print. | 133 // Current page number to print. |
126 PageNumber page_number_; | 134 PageNumber page_number_; |
127 | 135 |
128 // Used to generate a WeakPtr for callbacks. | 136 // Used to generate a WeakPtr for callbacks. |
129 base::WeakPtrFactory<PrintJobWorker> weak_factory_; | 137 base::WeakPtrFactory<PrintJobWorker> weak_factory_; |
130 | 138 |
131 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); | 139 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); |
132 }; | 140 }; |
133 | 141 |
134 } // namespace printing | 142 } // namespace printing |
135 | 143 |
136 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 144 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
OLD | NEW |