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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
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 #include "chrome/browser/printing/print_job.h" 5 #include "chrome/browser/printing/print_job.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/timer.h" 9 #include "base/timer.h"
10 #include "chrome/browser/printing/print_job_worker.h" 10 #include "chrome/browser/printing/print_job_worker.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "content/common/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "printing/printed_document.h" 13 #include "printing/printed_document.h"
14 #include "printing/printed_page.h" 14 #include "printing/printed_page.h"
15 15
16 using base::TimeDelta; 16 using base::TimeDelta;
17 17
18 namespace printing { 18 namespace printing {
19 19
20 PrintJob::PrintJob() 20 PrintJob::PrintJob()
21 : ui_message_loop_(MessageLoop::current()), 21 : ui_message_loop_(MessageLoop::current()),
22 source_(NULL), 22 source_(NULL),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // Real work is done in PrintJobWorker::StartPrinting(). 118 // Real work is done in PrintJobWorker::StartPrinting().
119 worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 119 worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
120 worker_.get(), &PrintJobWorker::StartPrinting, document_)); 120 worker_.get(), &PrintJobWorker::StartPrinting, document_));
121 // Set the flag right now. 121 // Set the flag right now.
122 is_job_pending_ = true; 122 is_job_pending_ = true;
123 123
124 // Tell everyone! 124 // Tell everyone!
125 scoped_refptr<JobEventDetails> details( 125 scoped_refptr<JobEventDetails> details(
126 new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL)); 126 new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL));
127 NotificationService::current()->Notify( 127 content::NotificationService::current()->Notify(
128 chrome::NOTIFICATION_PRINT_JOB_EVENT, 128 chrome::NOTIFICATION_PRINT_JOB_EVENT,
129 content::Source<PrintJob>(this), 129 content::Source<PrintJob>(this),
130 content::Details<JobEventDetails>(details.get())); 130 content::Details<JobEventDetails>(details.get()));
131 } 131 }
132 132
133 void PrintJob::Stop() { 133 void PrintJob::Stop() {
134 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 134 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
135 135
136 // Be sure to live long enough. 136 // Be sure to live long enough.
137 scoped_refptr<PrintJob> handle(this); 137 scoped_refptr<PrintJob> handle(this);
(...skipping 21 matching lines...) Expand all
159 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 159 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
160 MessageLoop* worker_loop = worker_.get() ? worker_->message_loop() : NULL; 160 MessageLoop* worker_loop = worker_.get() ? worker_->message_loop() : NULL;
161 if (worker_loop) { 161 if (worker_loop) {
162 // Call this right now so it renders the context invalid. Do not use 162 // Call this right now so it renders the context invalid. Do not use
163 // InvokeLater since it would take too much time. 163 // InvokeLater since it would take too much time.
164 worker_->Cancel(); 164 worker_->Cancel();
165 } 165 }
166 // Make sure a Cancel() is broadcast. 166 // Make sure a Cancel() is broadcast.
167 scoped_refptr<JobEventDetails> details( 167 scoped_refptr<JobEventDetails> details(
168 new JobEventDetails(JobEventDetails::FAILED, NULL, NULL)); 168 new JobEventDetails(JobEventDetails::FAILED, NULL, NULL));
169 NotificationService::current()->Notify( 169 content::NotificationService::current()->Notify(
170 chrome::NOTIFICATION_PRINT_JOB_EVENT, 170 chrome::NOTIFICATION_PRINT_JOB_EVENT,
171 content::Source<PrintJob>(this), 171 content::Source<PrintJob>(this),
172 content::Details<JobEventDetails>(details.get())); 172 content::Details<JobEventDetails>(details.get()));
173 Stop(); 173 Stop();
174 is_canceling_ = false; 174 is_canceling_ = false;
175 } 175 }
176 176
177 bool PrintJob::FlushJob(int timeout_ms) { 177 bool PrintJob::FlushJob(int timeout_ms) {
178 // Make sure the object outlive this message loop. 178 // Make sure the object outlive this message loop.
179 scoped_refptr<PrintJob> handle(this); 179 scoped_refptr<PrintJob> handle(this);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 void PrintJob::OnDocumentDone() { 266 void PrintJob::OnDocumentDone() {
267 // Be sure to live long enough. The instance could be destroyed by the 267 // Be sure to live long enough. The instance could be destroyed by the
268 // JOB_DONE broadcast. 268 // JOB_DONE broadcast.
269 scoped_refptr<PrintJob> handle(this); 269 scoped_refptr<PrintJob> handle(this);
270 270
271 // Stop the worker thread. 271 // Stop the worker thread.
272 Stop(); 272 Stop();
273 273
274 scoped_refptr<JobEventDetails> details( 274 scoped_refptr<JobEventDetails> details(
275 new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL)); 275 new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL));
276 NotificationService::current()->Notify( 276 content::NotificationService::current()->Notify(
277 chrome::NOTIFICATION_PRINT_JOB_EVENT, 277 chrome::NOTIFICATION_PRINT_JOB_EVENT,
278 content::Source<PrintJob>(this), 278 content::Source<PrintJob>(this),
279 content::Details<JobEventDetails>(details.get())); 279 content::Details<JobEventDetails>(details.get()));
280 } 280 }
281 281
282 void PrintJob::ControlledWorkerShutdown() { 282 void PrintJob::ControlledWorkerShutdown() {
283 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 283 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
284 284
285 // The deadlock this code works around is specific to window messaging on 285 // The deadlock this code works around is specific to window messaging on
286 // Windows, so we aren't likely to need it on any other platforms. 286 // Windows, so we aren't likely to need it on any other platforms.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 PrintedDocument* JobEventDetails::document() const { 348 PrintedDocument* JobEventDetails::document() const {
349 return document_; 349 return document_;
350 } 350 }
351 351
352 PrintedPage* JobEventDetails::page() const { 352 PrintedPage* JobEventDetails::page() const {
353 return page_; 353 return page_;
354 } 354 }
355 355
356 } // namespace printing 356 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud_uitest.cc ('k') | chrome/browser/printing/print_job_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698