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/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 namespace base { |
17 class DictionaryValue; | 18 class DictionaryValue; |
| 19 } |
18 | 20 |
19 namespace printing { | 21 namespace printing { |
20 | 22 |
21 class PrintedDocument; | 23 class PrintedDocument; |
22 class PrintedPage; | 24 class PrintedPage; |
23 class PrintJob; | 25 class PrintJob; |
24 class PrintJobWorkerOwner; | 26 class PrintJobWorkerOwner; |
25 | 27 |
26 // Worker thread code. All this code, except for the constructor, is executed in | 28 // Worker thread code. All this code, except for the constructor, is executed in |
27 // the worker thread. It manages the PrintingContext, which can be blocking | 29 // the worker thread. It manages the PrintingContext, which can be blocking |
(...skipping 11 matching lines...) Expand all Loading... |
39 // Initializes the print settings. If |ask_user_for_settings| is true, a | 41 // Initializes the print settings. If |ask_user_for_settings| is true, a |
40 // Print... dialog box will be shown to ask the user his preference. | 42 // Print... dialog box will be shown to ask the user his preference. |
41 void GetSettings(bool ask_user_for_settings, | 43 void GetSettings(bool ask_user_for_settings, |
42 gfx::NativeView parent_view, | 44 gfx::NativeView parent_view, |
43 int document_page_count, | 45 int document_page_count, |
44 bool has_selection, | 46 bool has_selection, |
45 bool use_overlays); | 47 bool use_overlays); |
46 | 48 |
47 // Set the new print settings. This function takes ownership of | 49 // Set the new print settings. This function takes ownership of |
48 // |new_settings|. | 50 // |new_settings|. |
49 void SetSettings(const DictionaryValue* const new_settings); | 51 void SetSettings(const base::DictionaryValue* const new_settings); |
50 | 52 |
51 // Starts the printing loop. Every pages are printed as soon as the data is | 53 // Starts the printing loop. Every pages are printed as soon as the data is |
52 // available. Makes sure the new_document is the right one. | 54 // available. Makes sure the new_document is the right one. |
53 void StartPrinting(PrintedDocument* new_document); | 55 void StartPrinting(PrintedDocument* new_document); |
54 | 56 |
55 // Updates the printed document. | 57 // Updates the printed document. |
56 void OnDocumentChanged(PrintedDocument* new_document); | 58 void OnDocumentChanged(PrintedDocument* new_document); |
57 | 59 |
58 // Unqueues waiting pages. Called when PrintJob receives a | 60 // Unqueues waiting pages. Called when PrintJob receives a |
59 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if | 61 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 int document_page_count, | 95 int document_page_count, |
94 bool has_selection); | 96 bool has_selection); |
95 | 97 |
96 // The callback used by PrintingContext::GetSettingsWithUI() to notify this | 98 // The callback used by PrintingContext::GetSettingsWithUI() to notify this |
97 // object that the print settings are set. This is needed in order to bounce | 99 // object that the print settings are set. This is needed in order to bounce |
98 // back into the IO thread for GetSettingsDone(). | 100 // back into the IO thread for GetSettingsDone(). |
99 void GetSettingsWithUIDone(PrintingContext::Result result); | 101 void GetSettingsWithUIDone(PrintingContext::Result result); |
100 | 102 |
101 // Called on the UI thread to update the print settings. This function takes | 103 // Called on the UI thread to update the print settings. This function takes |
102 // the ownership of |new_settings|. | 104 // the ownership of |new_settings|. |
103 void UpdatePrintSettings(const DictionaryValue* const new_settings); | 105 void UpdatePrintSettings(const base::DictionaryValue* const new_settings); |
104 | 106 |
105 // Reports settings back to owner_. | 107 // Reports settings back to owner_. |
106 void GetSettingsDone(PrintingContext::Result result); | 108 void GetSettingsDone(PrintingContext::Result result); |
107 | 109 |
108 // Use the default settings. When using GTK+ or Mac, this can still end up | 110 // Use the default settings. When using GTK+ or Mac, this can still end up |
109 // displaying a dialog. So this needs to happen from the UI thread on these | 111 // displaying a dialog. So this needs to happen from the UI thread on these |
110 // systems. | 112 // systems. |
111 void UseDefaultSettings(); | 113 void UseDefaultSettings(); |
112 | 114 |
113 // Information about the printer setting. | 115 // Information about the printer setting. |
(...skipping 16 matching lines...) Expand all Loading... |
130 | 132 |
131 template <> | 133 template <> |
132 struct RunnableMethodTraits<printing::PrintJobWorker> { | 134 struct RunnableMethodTraits<printing::PrintJobWorker> { |
133 void RetainCallee(printing::PrintJobWorker* obj); | 135 void RetainCallee(printing::PrintJobWorker* obj); |
134 void ReleaseCallee(printing::PrintJobWorker* obj); | 136 void ReleaseCallee(printing::PrintJobWorker* obj); |
135 private: | 137 private: |
136 scoped_refptr<printing::PrintJobWorkerOwner> owner_; | 138 scoped_refptr<printing::PrintJobWorkerOwner> owner_; |
137 }; | 139 }; |
138 | 140 |
139 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 141 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
OLD | NEW |