OLD | NEW |
---|---|
1 // Copyright (c) 2010 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/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "base/task.h" | 11 #include "base/task.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/printing_context.h" | 14 #include "printing/printing_context.h" |
15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
16 | 16 |
17 class DictionaryValue; | |
18 | |
17 namespace printing { | 19 namespace printing { |
18 | 20 |
19 class PrintedDocument; | 21 class PrintedDocument; |
20 class PrintedPage; | 22 class PrintedPage; |
21 class PrintJob; | 23 class PrintJob; |
22 class PrintJobWorkerOwner; | 24 class PrintJobWorkerOwner; |
23 | 25 |
24 // Worker thread code. All this code, except for the constructor, is executed in | 26 // Worker thread code. All this code, except for the constructor, is executed in |
25 // the worker thread. It manages the PrintingContext, which can be blocking | 27 // the worker thread. It manages the PrintingContext, which can be blocking |
26 // and/or run a message loop. This is the object that generates most | 28 // and/or run a message loop. This is the object that generates most |
27 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a | 29 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a |
28 // NotificationTask task to be executed from the right thread, the UI thread. | 30 // NotificationTask task to be executed from the right thread, the UI thread. |
29 // PrintJob always outlives its worker instance. | 31 // PrintJob always outlives its worker instance. |
30 class PrintJobWorker : public base::Thread { | 32 class PrintJobWorker : public base::Thread { |
31 public: | 33 public: |
32 explicit PrintJobWorker(PrintJobWorkerOwner* owner); | 34 explicit PrintJobWorker(PrintJobWorkerOwner* owner); |
33 ~PrintJobWorker(); | 35 ~PrintJobWorker(); |
34 | 36 |
35 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 37 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
36 | 38 |
37 // Initializes the print settings. If |ask_user_for_settings| is true, a | 39 // Initializes the print settings. If |ask_user_for_settings| is true, a |
38 // Print... dialog box will be shown to ask the user his preference. | 40 // Print... dialog box will be shown to ask the user his preference. |
39 void GetSettings(bool ask_user_for_settings, | 41 void GetSettings(bool ask_user_for_settings, |
40 gfx::NativeView parent_view, | 42 gfx::NativeView parent_view, |
41 int document_page_count, | 43 int document_page_count, |
42 bool has_selection, | 44 bool has_selection, |
43 bool use_overlays); | 45 bool use_overlays); |
44 | 46 |
47 // Set the new print settings. | |
48 void SetSettings(const DictionaryValue* const new_settings); | |
Lei Zhang
2011/03/03 00:22:44
You probably should mention SetSettings() takes ow
kmadhusu
2011/03/04 19:39:02
Done.
| |
49 | |
45 // Starts the printing loop. Every pages are printed as soon as the data is | 50 // Starts the printing loop. Every pages are printed as soon as the data is |
46 // available. Makes sure the new_document is the right one. | 51 // available. Makes sure the new_document is the right one. |
47 void StartPrinting(PrintedDocument* new_document); | 52 void StartPrinting(PrintedDocument* new_document); |
48 | 53 |
49 // Updates the printed document. | 54 // Updates the printed document. |
50 void OnDocumentChanged(PrintedDocument* new_document); | 55 void OnDocumentChanged(PrintedDocument* new_document); |
51 | 56 |
52 // Unqueues waiting pages. Called when PrintJob receives a | 57 // Unqueues waiting pages. Called when PrintJob receives a |
53 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if | 58 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if |
54 // the next page can be printed. | 59 // the next page can be printed. |
(...skipping 30 matching lines...) Expand all Loading... | |
85 // but sticks with this for consistency. | 90 // but sticks with this for consistency. |
86 void GetSettingsWithUI(gfx::NativeView parent_view, | 91 void GetSettingsWithUI(gfx::NativeView parent_view, |
87 int document_page_count, | 92 int document_page_count, |
88 bool has_selection); | 93 bool has_selection); |
89 | 94 |
90 // The callback used by PrintingContext::GetSettingsWithUI() to notify this | 95 // The callback used by PrintingContext::GetSettingsWithUI() to notify this |
91 // object that the print settings are set. This is needed in order to bounce | 96 // object that the print settings are set. This is needed in order to bounce |
92 // back into the IO thread for GetSettingsDone(). | 97 // back into the IO thread for GetSettingsDone(). |
93 void GetSettingsWithUIDone(PrintingContext::Result result); | 98 void GetSettingsWithUIDone(PrintingContext::Result result); |
94 | 99 |
100 // Called on the UI thread to update the print settings. | |
101 void UpdatePrintSettings(const DictionaryValue* const new_settings); | |
102 | |
95 // Reports settings back to owner_. | 103 // Reports settings back to owner_. |
96 void GetSettingsDone(PrintingContext::Result result); | 104 void GetSettingsDone(PrintingContext::Result result); |
97 | 105 |
98 // Use the default settings. When using GTK+ or Mac, this can still end up | 106 // Use the default settings. When using GTK+ or Mac, this can still end up |
99 // displaying a dialog. So this needs to happen from the UI thread on these | 107 // displaying a dialog. So this needs to happen from the UI thread on these |
100 // systems. | 108 // systems. |
101 void UseDefaultSettings(); | 109 void UseDefaultSettings(); |
102 | 110 |
103 // Information about the printer setting. | 111 // Information about the printer setting. |
104 scoped_ptr<PrintingContext> printing_context_; | 112 scoped_ptr<PrintingContext> printing_context_; |
(...skipping 15 matching lines...) Expand all Loading... | |
120 | 128 |
121 template <> | 129 template <> |
122 struct RunnableMethodTraits<printing::PrintJobWorker> { | 130 struct RunnableMethodTraits<printing::PrintJobWorker> { |
123 void RetainCallee(printing::PrintJobWorker* obj); | 131 void RetainCallee(printing::PrintJobWorker* obj); |
124 void ReleaseCallee(printing::PrintJobWorker* obj); | 132 void ReleaseCallee(printing::PrintJobWorker* obj); |
125 private: | 133 private: |
126 scoped_refptr<printing::PrintJobWorkerOwner> owner_; | 134 scoped_refptr<printing::PrintJobWorkerOwner> owner_; |
127 }; | 135 }; |
128 | 136 |
129 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 137 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
OLD | NEW |