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

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

Issue 149148: Remove unused notification in print code to simplify before refactoring.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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_main.cc ('k') | chrome/browser/printing/print_job_manager.h » ('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) 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 #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/timer.h" 8 #include "base/timer.h"
9 #include "chrome/browser/printing/print_job_worker.h" 9 #include "chrome/browser/printing/print_job_worker.h"
10 #include "chrome/browser/printing/printed_document.h" 10 #include "chrome/browser/printing/printed_document.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Don't forget to register to our own messages. 59 // Don't forget to register to our own messages.
60 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, 60 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT,
61 Source<PrintJob>(this)); 61 Source<PrintJob>(this));
62 } 62 }
63 63
64 void PrintJob::Observe(NotificationType type, 64 void PrintJob::Observe(NotificationType type,
65 const NotificationSource& source, 65 const NotificationSource& source,
66 const NotificationDetails& details) { 66 const NotificationDetails& details) {
67 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 67 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
68 switch (type.value) { 68 switch (type.value) {
69 case NotificationType::PRINTED_DOCUMENT_UPDATED: {
70 DCHECK(Source<PrintedDocument>(source).ptr() ==
71 document_.get());
72
73 // This notification may happens even if no job is started (i.e. print
74 // preview)
75 if (is_job_pending_ == true &&
76 Source<PrintedDocument>(source).ptr() == document_.get() &&
77 Details<PrintedPage>(details).ptr() != NULL) {
78 // Are we waiting for a page to print? The worker will know.
79 worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
80 worker_.get(), &PrintJobWorker::OnNewPage));
81 }
82 break;
83 }
84 case NotificationType::PRINT_JOB_EVENT: { 69 case NotificationType::PRINT_JOB_EVENT: {
85 OnNotifyPrintJobEvent(*Details<JobEventDetails>(details).ptr()); 70 OnNotifyPrintJobEvent(*Details<JobEventDetails>(details).ptr());
86 break; 71 break;
87 } 72 }
88 default: { 73 default: {
89 break; 74 break;
90 } 75 }
91 } 76 }
92 } 77 }
93 78
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return is_print_dialog_box_shown_; 207 return is_print_dialog_box_shown_;
223 } 208 }
224 209
225 PrintedDocument* PrintJob::document() const { 210 PrintedDocument* PrintJob::document() const {
226 return document_.get(); 211 return document_.get();
227 } 212 }
228 213
229 void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) { 214 void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
230 if (document_.get() == new_document) 215 if (document_.get() == new_document)
231 return; 216 return;
232 // Unregisters. 217
233 if (document_.get()) {
234 registrar_.Remove(this, NotificationType::PRINTED_DOCUMENT_UPDATED,
235 Source<PrintedDocument>(document_.get()));
236 }
237 document_ = new_document; 218 document_ = new_document;
238 219
239 // Registers.
240 if (document_.get()) { 220 if (document_.get()) {
241 registrar_.Add(this, NotificationType::PRINTED_DOCUMENT_UPDATED,
242 Source<PrintedDocument>(document_.get()));
243 settings_ = document_->settings(); 221 settings_ = document_->settings();
244 } 222 }
245 223
246 if (worker_.get() && worker_->message_loop()) { 224 if (worker_.get() && worker_->message_loop()) {
247 DCHECK(!is_job_pending_); 225 DCHECK(!is_job_pending_);
248 // Sync the document with the worker. 226 // Sync the document with the worker.
249 worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 227 worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
250 worker_.get(), &PrintJobWorker::OnDocumentChanged, document_)); 228 worker_.get(), &PrintJobWorker::OnDocumentChanged, document_));
251 } 229 }
252 } 230 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 342
365 PrintedDocument* JobEventDetails::document() const { 343 PrintedDocument* JobEventDetails::document() const {
366 return document_; 344 return document_;
367 } 345 }
368 346
369 PrintedPage* JobEventDetails::page() const { 347 PrintedPage* JobEventDetails::page() const {
370 return page_; 348 return page_;
371 } 349 }
372 350
373 } // namespace printing 351 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/printing/print_job_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698