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

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

Issue 2692923006: Add job id to JobEventDetails. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/printing/print_job.h ('k') | chrome/browser/printing/print_job_worker.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) 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 #include "chrome/browser/printing/print_job.h" 5 #include "chrome/browser/printing/print_job.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Real work is done in PrintJobWorker::StartPrinting(). 130 // Real work is done in PrintJobWorker::StartPrinting().
131 worker_->PostTask(FROM_HERE, 131 worker_->PostTask(FROM_HERE,
132 base::Bind(&HoldRefCallback, make_scoped_refptr(this), 132 base::Bind(&HoldRefCallback, make_scoped_refptr(this),
133 base::Bind(&PrintJobWorker::StartPrinting, 133 base::Bind(&PrintJobWorker::StartPrinting,
134 base::Unretained(worker_.get()), 134 base::Unretained(worker_.get()),
135 base::RetainedRef(document_)))); 135 base::RetainedRef(document_))));
136 // Set the flag right now. 136 // Set the flag right now.
137 is_job_pending_ = true; 137 is_job_pending_ = true;
138 138
139 // Tell everyone! 139 // Tell everyone!
140 scoped_refptr<JobEventDetails> details( 140 scoped_refptr<JobEventDetails> details(new JobEventDetails(
141 new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), nullptr)); 141 JobEventDetails::NEW_DOC, 0, document_.get(), nullptr));
142 content::NotificationService::current()->Notify( 142 content::NotificationService::current()->Notify(
143 chrome::NOTIFICATION_PRINT_JOB_EVENT, 143 chrome::NOTIFICATION_PRINT_JOB_EVENT,
144 content::Source<PrintJob>(this), 144 content::Source<PrintJob>(this),
145 content::Details<JobEventDetails>(details.get())); 145 content::Details<JobEventDetails>(details.get()));
146 } 146 }
147 147
148 void PrintJob::Stop() { 148 void PrintJob::Stop() {
149 DCHECK(RunsTasksOnCurrentThread()); 149 DCHECK(RunsTasksOnCurrentThread());
150 150
151 if (quit_factory_.HasWeakPtrs()) { 151 if (quit_factory_.HasWeakPtrs()) {
(...skipping 24 matching lines...) Expand all
176 scoped_refptr<PrintJob> handle(this); 176 scoped_refptr<PrintJob> handle(this);
177 177
178 DCHECK(RunsTasksOnCurrentThread()); 178 DCHECK(RunsTasksOnCurrentThread());
179 if (worker_ && worker_->IsRunning()) { 179 if (worker_ && worker_->IsRunning()) {
180 // Call this right now so it renders the context invalid. Do not use 180 // Call this right now so it renders the context invalid. Do not use
181 // InvokeLater since it would take too much time. 181 // InvokeLater since it would take too much time.
182 worker_->Cancel(); 182 worker_->Cancel();
183 } 183 }
184 // Make sure a Cancel() is broadcast. 184 // Make sure a Cancel() is broadcast.
185 scoped_refptr<JobEventDetails> details( 185 scoped_refptr<JobEventDetails> details(
186 new JobEventDetails(JobEventDetails::FAILED, nullptr, nullptr)); 186 new JobEventDetails(JobEventDetails::FAILED, 0, nullptr, nullptr));
187 content::NotificationService::current()->Notify( 187 content::NotificationService::current()->Notify(
188 chrome::NOTIFICATION_PRINT_JOB_EVENT, 188 chrome::NOTIFICATION_PRINT_JOB_EVENT,
189 content::Source<PrintJob>(this), 189 content::Source<PrintJob>(this),
190 content::Details<JobEventDetails>(details.get())); 190 content::Details<JobEventDetails>(details.get()));
191 Stop(); 191 Stop();
192 is_canceling_ = false; 192 is_canceling_ = false;
193 } 193 }
194 194
195 bool PrintJob::FlushJob(base::TimeDelta timeout) { 195 bool PrintJob::FlushJob(base::TimeDelta timeout) {
196 // Make sure the object outlive this message loop. 196 // Make sure the object outlive this message loop.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 401 }
402 402
403 void PrintJob::OnDocumentDone() { 403 void PrintJob::OnDocumentDone() {
404 // Be sure to live long enough. The instance could be destroyed by the 404 // Be sure to live long enough. The instance could be destroyed by the
405 // JOB_DONE broadcast. 405 // JOB_DONE broadcast.
406 scoped_refptr<PrintJob> handle(this); 406 scoped_refptr<PrintJob> handle(this);
407 407
408 // Stop the worker thread. 408 // Stop the worker thread.
409 Stop(); 409 Stop();
410 410
411 scoped_refptr<JobEventDetails> details( 411 scoped_refptr<JobEventDetails> details(new JobEventDetails(
412 new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), nullptr)); 412 JobEventDetails::JOB_DONE, 0, document_.get(), nullptr));
413 content::NotificationService::current()->Notify( 413 content::NotificationService::current()->Notify(
414 chrome::NOTIFICATION_PRINT_JOB_EVENT, 414 chrome::NOTIFICATION_PRINT_JOB_EVENT,
415 content::Source<PrintJob>(this), 415 content::Source<PrintJob>(this),
416 content::Details<JobEventDetails>(details.get())); 416 content::Details<JobEventDetails>(details.get()));
417 } 417 }
418 418
419 void PrintJob::ControlledWorkerShutdown() { 419 void PrintJob::ControlledWorkerShutdown() {
420 DCHECK(RunsTasksOnCurrentThread()); 420 DCHECK(RunsTasksOnCurrentThread());
421 421
422 // The deadlock this code works around is specific to window messaging on 422 // The deadlock this code works around is specific to window messaging on
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 void PrintJob::HoldUntilStopIsCalled() { 460 void PrintJob::HoldUntilStopIsCalled() {
461 } 461 }
462 462
463 void PrintJob::Quit() { 463 void PrintJob::Quit() {
464 base::MessageLoop::current()->QuitWhenIdle(); 464 base::MessageLoop::current()->QuitWhenIdle();
465 } 465 }
466 466
467 // Takes settings_ ownership and will be deleted in the receiving thread. 467 // Takes settings_ ownership and will be deleted in the receiving thread.
468 JobEventDetails::JobEventDetails(Type type, 468 JobEventDetails::JobEventDetails(Type type,
469 int job_id,
469 PrintedDocument* document, 470 PrintedDocument* document,
470 PrintedPage* page) 471 PrintedPage* page)
471 : document_(document), 472 : document_(document), page_(page), type_(type), job_id_(job_id) {}
472 page_(page),
473 type_(type) {
474 }
475 473
476 JobEventDetails::~JobEventDetails() { 474 JobEventDetails::~JobEventDetails() {
477 } 475 }
478 476
479 PrintedDocument* JobEventDetails::document() const { return document_.get(); } 477 PrintedDocument* JobEventDetails::document() const { return document_.get(); }
480 478
481 PrintedPage* JobEventDetails::page() const { return page_.get(); } 479 PrintedPage* JobEventDetails::page() const { return page_.get(); }
482 480
483 } // namespace printing 481 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_job.h ('k') | chrome/browser/printing/print_job_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698