Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/printing/print_job_worker.h

Issue 276004: Wire up printing on the Mac (Closed)
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "app/gfx/native_widget_types.h"
8 #include "base/task.h" 9 #include "base/task.h"
9 #include "base/thread.h" 10 #include "base/thread.h"
10 #include "printing/page_number.h" 11 #include "printing/page_number.h"
11 #include "printing/printing_context.h" 12 #include "printing/printing_context.h"
12 13
13 namespace printing { 14 namespace printing {
14 15
15 class PrintedDocument; 16 class PrintedDocument;
16 class PrintedPage; 17 class PrintedPage;
17 class PrintJob; 18 class PrintJob;
18 class PrintJobWorkerOwner; 19 class PrintJobWorkerOwner;
19 20
20 // Worker thread code. All this code, except for the constructor, is executed in 21 // Worker thread code. All this code, except for the constructor, is executed in
21 // the worker thread. It manages the PrintingContext, which can be blocking 22 // the worker thread. It manages the PrintingContext, which can be blocking
22 // and/or run a message loop. This is the object that generates most 23 // and/or run a message loop. This is the object that generates most
23 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a 24 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a
24 // NotificationTask task to be executed from the right thread, the UI thread. 25 // NotificationTask task to be executed from the right thread, the UI thread.
25 // PrintJob always outlives its worker instance. 26 // PrintJob always outlives its worker instance.
26 class PrintJobWorker : public base::Thread { 27 class PrintJobWorker : public base::Thread {
27 public: 28 public:
28 explicit PrintJobWorker(PrintJobWorkerOwner* owner); 29 explicit PrintJobWorker(PrintJobWorkerOwner* owner);
29 ~PrintJobWorker(); 30 ~PrintJobWorker();
30 31
31 void SetNewOwner(PrintJobWorkerOwner* new_owner); 32 void SetNewOwner(PrintJobWorkerOwner* new_owner);
32 33
33 // Initializes the print settings. If |ask_user_for_settings| is true, a 34 // Initializes the print settings. If |ask_user_for_settings| is true, a
34 // Print... dialog box will be shown to ask the user his preference. 35 // Print... dialog box will be shown to ask the user his preference.
35 void GetSettings(bool ask_user_for_settings, 36 void GetSettings(bool ask_user_for_settings,
36 HWND parent_window, 37 gfx::NativeWindow parent_window,
37 int document_page_count, 38 int document_page_count,
38 bool has_selection); 39 bool has_selection);
39 40
40 // Starts the printing loop. Every pages are printed as soon as the data is 41 // Starts the printing loop. Every pages are printed as soon as the data is
41 // available. Makes sure the new_document is the right one. 42 // available. Makes sure the new_document is the right one.
42 void StartPrinting(PrintedDocument* new_document); 43 void StartPrinting(PrintedDocument* new_document);
43 44
44 // Updates the printed document. 45 // Updates the printed document.
45 void OnDocumentChanged(PrintedDocument* new_document); 46 void OnDocumentChanged(PrintedDocument* new_document);
46 47
(...skipping 24 matching lines...) Expand all
71 // Renders a page in the printer. 72 // Renders a page in the printer.
72 void SpoolPage(PrintedPage& page); 73 void SpoolPage(PrintedPage& page);
73 74
74 // Closes the job since spooling is done. 75 // Closes the job since spooling is done.
75 void OnDocumentDone(); 76 void OnDocumentDone();
76 77
77 // Discards the current document, the current page and cancels the printing 78 // Discards the current document, the current page and cancels the printing
78 // context. 79 // context.
79 void OnFailure(); 80 void OnFailure();
80 81
82 #if defined(OS_MACOSX)
83 // Asks the user for print settings. Must be called on the UI thread.
pink (ping after 24hrs) 2009/10/13 21:04:51 Perhaps add that this has to be added because it n
stuartmorgan 2009/10/13 22:07:43 Done.
84 void GetSettingsWithUI(gfx::NativeWindow parent_window,
85 int document_page_count,
86 bool has_selection);
87 #endif
88
89 // Reports settings back to owner_.
90 void GetSettingsDone(PrintingContext::Result result);
91
81 // Information about the printer setting. 92 // Information about the printer setting.
82 PrintingContext printing_context_; 93 PrintingContext printing_context_;
83 94
84 // The printed document. Only has read-only access. 95 // The printed document. Only has read-only access.
85 scoped_refptr<PrintedDocument> document_; 96 scoped_refptr<PrintedDocument> document_;
86 97
87 // The print job owning this worker thread. It is guaranteed to outlive this 98 // The print job owning this worker thread. It is guaranteed to outlive this
88 // object. 99 // object.
89 PrintJobWorkerOwner* owner_; 100 PrintJobWorkerOwner* owner_;
90 101
91 // Current page number to print. 102 // Current page number to print.
92 PageNumber page_number_; 103 PageNumber page_number_;
93 104
94 DISALLOW_EVIL_CONSTRUCTORS(PrintJobWorker); 105 DISALLOW_EVIL_CONSTRUCTORS(PrintJobWorker);
95 }; 106 };
96 107
97 } // namespace printing 108 } // namespace printing
98 109
99 template <> 110 template <>
100 struct RunnableMethodTraits<printing::PrintJobWorker> { 111 struct RunnableMethodTraits<printing::PrintJobWorker> {
101 void RetainCallee(printing::PrintJobWorker* obj); 112 void RetainCallee(printing::PrintJobWorker* obj);
102 void ReleaseCallee(printing::PrintJobWorker* obj); 113 void ReleaseCallee(printing::PrintJobWorker* obj);
103 private: 114 private:
104 scoped_refptr<printing::PrintJobWorkerOwner> owner_; 115 scoped_refptr<printing::PrintJobWorkerOwner> owner_;
105 }; 116 };
106 117
107 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ 118 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698