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

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

Issue 10383254: At browser exit, wait for pending print jobs before starting shutdown. This is to avoid a nested me… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/printing/print_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.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/message_loop.h" 12 #include "base/message_loop.h"
12 #include "chrome/browser/printing/print_job_worker_owner.h" 13 #include "chrome/browser/printing/print_job_worker_owner.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 16
16 class Thread; 17 class Thread;
17 18
18 namespace printing { 19 namespace printing {
19 20
20 // See definition below. 21 // See definition below.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void OnNotifyPrintJobEvent(const JobEventDetails& event_details); 102 void OnNotifyPrintJobEvent(const JobEventDetails& event_details);
102 103
103 // Releases the worker thread by calling Stop(), then broadcasts a JOB_DONE 104 // Releases the worker thread by calling Stop(), then broadcasts a JOB_DONE
104 // notification. 105 // notification.
105 void OnDocumentDone(); 106 void OnDocumentDone();
106 107
107 // Terminates the worker thread in a very controlled way, to work around any 108 // Terminates the worker thread in a very controlled way, to work around any
108 // eventual deadlock. 109 // eventual deadlock.
109 void ControlledWorkerShutdown(); 110 void ControlledWorkerShutdown();
110 111
112 // Called at shutdown when running a nested message loop.
113 void Quit();
114
111 content::NotificationRegistrar registrar_; 115 content::NotificationRegistrar registrar_;
112 116
113 // Main message loop reference. Used to send notifications in the right 117 // Main message loop reference. Used to send notifications in the right
114 // thread. 118 // thread.
115 MessageLoop* const ui_message_loop_; 119 MessageLoop* const ui_message_loop_;
116 120
117 // Source that generates the PrintedPage's (i.e. a WebContents). It will be 121 // Source that generates the PrintedPage's (i.e. a WebContents). It will be
118 // set back to NULL if the source is deleted before this object. 122 // set back to NULL if the source is deleted before this object.
119 PrintedPagesSource* source_; 123 PrintedPagesSource* source_;
120 124
121 // All the UI is done in a worker thread because many Win32 print functions 125 // All the UI is done in a worker thread because many Win32 print functions
122 // are blocking and enters a message loop without your consent. There is one 126 // are blocking and enters a message loop without your consent. There is one
123 // worker thread per print job. 127 // worker thread per print job.
124 scoped_ptr<PrintJobWorker> worker_; 128 scoped_ptr<PrintJobWorker> worker_;
125 129
126 // Cache of the print context settings for access in the UI thread. 130 // Cache of the print context settings for access in the UI thread.
127 PrintSettings settings_; 131 PrintSettings settings_;
128 132
129 // The printed document. 133 // The printed document.
130 scoped_refptr<PrintedDocument> document_; 134 scoped_refptr<PrintedDocument> document_;
131 135
132 // Is the worker thread printing. 136 // Is the worker thread printing.
133 bool is_job_pending_; 137 bool is_job_pending_;
134 138
135 // Is Canceling? If so, try to not cause recursion if on FAILED notification, 139 // Is Canceling? If so, try to not cause recursion if on FAILED notification,
136 // the notified calls Cancel() again. 140 // the notified calls Cancel() again.
137 bool is_canceling_; 141 bool is_canceling_;
138 142
143 // Used at shutdown so that we can quit a nested message loop.
144 base::WeakPtrFactory<PrintJob> quit_factory_;
145
139 DISALLOW_COPY_AND_ASSIGN(PrintJob); 146 DISALLOW_COPY_AND_ASSIGN(PrintJob);
140 }; 147 };
141 148
142 // Details for a NOTIFY_PRINT_JOB_EVENT notification. The members may be NULL. 149 // Details for a NOTIFY_PRINT_JOB_EVENT notification. The members may be NULL.
143 class JobEventDetails : public base::RefCountedThreadSafe<JobEventDetails> { 150 class JobEventDetails : public base::RefCountedThreadSafe<JobEventDetails> {
144 public: 151 public:
145 // Event type. 152 // Event type.
146 enum Type { 153 enum Type {
147 // Print... dialog box has been closed with OK button. 154 // Print... dialog box has been closed with OK button.
148 USER_INIT_DONE, 155 USER_INIT_DONE,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 scoped_refptr<PrintedDocument> document_; 201 scoped_refptr<PrintedDocument> document_;
195 scoped_refptr<PrintedPage> page_; 202 scoped_refptr<PrintedPage> page_;
196 const Type type_; 203 const Type type_;
197 204
198 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); 205 DISALLOW_COPY_AND_ASSIGN(JobEventDetails);
199 }; 206 };
200 207
201 } // namespace printing 208 } // namespace printing
202 209
203 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ 210 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/printing/print_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698