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

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

Issue 566693002: Use file handles to interact with utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Sep 15 03:22:54 PDT 2014 Created 6 years, 3 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) 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_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.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/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "chrome/browser/printing/print_job_worker_owner.h" 12 #include "chrome/browser/printing/print_job_worker_owner.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 15
16 class Thread; 16 class Thread;
17 17
18 namespace base {
19 class RefCountedMemory;
20 }
21
18 namespace printing { 22 namespace printing {
19 23
20 // See definition below.
21 class JobEventDetails; 24 class JobEventDetails;
22 25 class MetafilePlayer;
26 class PdfToEmfConverter;
27 class PrintJobWorker;
23 class PrintedDocument; 28 class PrintedDocument;
24 class PrintedPage; 29 class PrintedPage;
25 class PrintedPagesSource; 30 class PrintedPagesSource;
26 class PrintJobWorker;
27 class PrinterQuery; 31 class PrinterQuery;
28 32
29 // Manages the print work for a specific document. Talks to the printer through 33 // Manages the print work for a specific document. Talks to the printer through
30 // PrintingContext through PrintJobWorker. Hides access to PrintingContext in a 34 // PrintingContext through PrintJobWorker. Hides access to PrintingContext in a
31 // worker thread so the caller never blocks. PrintJob will send notifications on 35 // worker thread so the caller never blocks. PrintJob will send notifications on
32 // any state change. While printing, the PrintJobManager instance keeps a 36 // any state change. While printing, the PrintJobManager instance keeps a
33 // reference to the job to be sure it is kept alive. All the code in this class 37 // reference to the job to be sure it is kept alive. All the code in this class
34 // runs in the UI thread. 38 // runs in the UI thread.
35 class PrintJob : public PrintJobWorkerOwner, 39 class PrintJob : public PrintJobWorkerOwner,
36 public content::NotificationObserver { 40 public content::NotificationObserver {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // the source is being destroyed. 83 // the source is being destroyed.
80 void DisconnectSource(); 84 void DisconnectSource();
81 85
82 // Returns true if the print job is pending, i.e. between a StartPrinting() 86 // Returns true if the print job is pending, i.e. between a StartPrinting()
83 // and the end of the spooling. 87 // and the end of the spooling.
84 bool is_job_pending() const; 88 bool is_job_pending() const;
85 89
86 // Access the current printed document. Warning: may be NULL. 90 // Access the current printed document. Warning: may be NULL.
87 PrintedDocument* document() const; 91 PrintedDocument* document() const;
88 92
93 #if defined(OS_WIN)
94 void ConvertPdfToEmf(const scoped_refptr<base::RefCountedMemory>& bytes,
95 gfx::Size page_size,
Lei Zhang 2014/09/15 21:49:53 nit: pass by reference?
Vitaly Buka (NO REVIEWS) 2014/09/15 22:33:50 Done.
96 gfx::Rect content_area);
97 #endif // OS_WIN
98
89 protected: 99 protected:
90 virtual ~PrintJob(); 100 virtual ~PrintJob();
91 101
92 private: 102 private:
93 // Updates document_ to a new instance. 103 // Updates document_ to a new instance.
94 void UpdatePrintedDocument(PrintedDocument* new_document); 104 void UpdatePrintedDocument(PrintedDocument* new_document);
95 105
96 // Processes a NOTIFY_PRINT_JOB_EVENT notification. 106 // Processes a NOTIFY_PRINT_JOB_EVENT notification.
97 void OnNotifyPrintJobEvent(const JobEventDetails& event_details); 107 void OnNotifyPrintJobEvent(const JobEventDetails& event_details);
98 108
99 // Releases the worker thread by calling Stop(), then broadcasts a JOB_DONE 109 // Releases the worker thread by calling Stop(), then broadcasts a JOB_DONE
100 // notification. 110 // notification.
101 void OnDocumentDone(); 111 void OnDocumentDone();
102 112
103 // Terminates the worker thread in a very controlled way, to work around any 113 // Terminates the worker thread in a very controlled way, to work around any
104 // eventual deadlock. 114 // eventual deadlock.
105 void ControlledWorkerShutdown(); 115 void ControlledWorkerShutdown();
106 116
107 // Called at shutdown when running a nested message loop. 117 // Called at shutdown when running a nested message loop.
108 void Quit(); 118 void Quit();
109 119
110 void HoldUntilStopIsCalled(); 120 void HoldUntilStopIsCalled();
111 121
122 #if defined(OS_WIN)
123 // Called on completion of converting the pdf to emf.
124 void OnPdfPageConvertedToEmf(int page_number,
125 double scale_factor,
126 scoped_ptr<MetafilePlayer> emf);
127 void OnPdfLoaded(int page_number);
128 #endif // OS_WIN
129
112 content::NotificationRegistrar registrar_; 130 content::NotificationRegistrar registrar_;
113 131
114 // Source that generates the PrintedPage's (i.e. a WebContents). It will be 132 // Source that generates the PrintedPage's (i.e. a WebContents). It will be
115 // set back to NULL if the source is deleted before this object. 133 // set back to NULL if the source is deleted before this object.
116 PrintedPagesSource* source_; 134 PrintedPagesSource* source_;
117 135
118 // All the UI is done in a worker thread because many Win32 print functions 136 // All the UI is done in a worker thread because many Win32 print functions
119 // are blocking and enters a message loop without your consent. There is one 137 // are blocking and enters a message loop without your consent. There is one
120 // worker thread per print job. 138 // worker thread per print job.
121 scoped_ptr<PrintJobWorker> worker_; 139 scoped_ptr<PrintJobWorker> worker_;
122 140
123 // Cache of the print context settings for access in the UI thread. 141 // Cache of the print context settings for access in the UI thread.
124 PrintSettings settings_; 142 PrintSettings settings_;
125 143
126 // The printed document. 144 // The printed document.
127 scoped_refptr<PrintedDocument> document_; 145 scoped_refptr<PrintedDocument> document_;
128 146
129 // Is the worker thread printing. 147 // Is the worker thread printing.
130 bool is_job_pending_; 148 bool is_job_pending_;
131 149
132 // Is Canceling? If so, try to not cause recursion if on FAILED notification, 150 // Is Canceling? If so, try to not cause recursion if on FAILED notification,
133 // the notified calls Cancel() again. 151 // the notified calls Cancel() again.
134 bool is_canceling_; 152 bool is_canceling_;
135 153
154 #if defined(OS_WIN)
155 scoped_ptr<PdfToEmfConverter> pdf_to_emf_converter_;
156 int pdf_to_emf_page_count_;
157 int pdf_to_emf_current_page_;
158 gfx::Size pdf_to_emf_page_size_;
159 gfx::Rect pdf_to_emf_content_area_;
160 #endif // OS_WIN
161
136 // Used at shutdown so that we can quit a nested message loop. 162 // Used at shutdown so that we can quit a nested message loop.
137 base::WeakPtrFactory<PrintJob> quit_factory_; 163 base::WeakPtrFactory<PrintJob> quit_factory_;
138 164
139 DISALLOW_COPY_AND_ASSIGN(PrintJob); 165 DISALLOW_COPY_AND_ASSIGN(PrintJob);
140 }; 166 };
141 167
142 // Details for a NOTIFY_PRINT_JOB_EVENT notification. The members may be NULL. 168 // Details for a NOTIFY_PRINT_JOB_EVENT notification. The members may be NULL.
143 class JobEventDetails : public base::RefCountedThreadSafe<JobEventDetails> { 169 class JobEventDetails : public base::RefCountedThreadSafe<JobEventDetails> {
144 public: 170 public:
145 // Event type. 171 // Event type.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 scoped_refptr<PrintedDocument> document_; 220 scoped_refptr<PrintedDocument> document_;
195 scoped_refptr<PrintedPage> page_; 221 scoped_refptr<PrintedPage> page_;
196 const Type type_; 222 const Type type_;
197 223
198 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); 224 DISALLOW_COPY_AND_ASSIGN(JobEventDetails);
199 }; 225 };
200 226
201 } // namespace printing 227 } // namespace printing
202 228
203 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ 229 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698