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

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

Issue 1815363002: Add RetainedRef uses where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 #include "chrome/browser/printing/print_job.h" 5 #include "chrome/browser/printing/print_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 void PrintJob::StartPrinting() { 125 void PrintJob::StartPrinting() {
126 DCHECK(RunsTasksOnCurrentThread()); 126 DCHECK(RunsTasksOnCurrentThread());
127 DCHECK(worker_->IsRunning()); 127 DCHECK(worker_->IsRunning());
128 DCHECK(!is_job_pending_); 128 DCHECK(!is_job_pending_);
129 if (!worker_->IsRunning() || is_job_pending_) 129 if (!worker_->IsRunning() || is_job_pending_)
130 return; 130 return;
131 131
132 // Real work is done in PrintJobWorker::StartPrinting(). 132 // Real work is done in PrintJobWorker::StartPrinting().
133 worker_->PostTask(FROM_HERE, 133 worker_->PostTask(FROM_HERE,
134 base::Bind(&HoldRefCallback, 134 base::Bind(&HoldRefCallback, make_scoped_refptr(this),
135 make_scoped_refptr(this),
136 base::Bind(&PrintJobWorker::StartPrinting, 135 base::Bind(&PrintJobWorker::StartPrinting,
137 base::Unretained(worker_.get()), 136 base::Unretained(worker_.get()),
138 document_))); 137 base::RetainedRef(document_))));
139 // Set the flag right now. 138 // Set the flag right now.
140 is_job_pending_ = true; 139 is_job_pending_ = true;
141 140
142 // Tell everyone! 141 // Tell everyone!
143 scoped_refptr<JobEventDetails> details( 142 scoped_refptr<JobEventDetails> details(
144 new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL)); 143 new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL));
145 content::NotificationService::current()->Notify( 144 content::NotificationService::current()->Notify(
146 chrome::NOTIFICATION_PRINT_JOB_EVENT, 145 chrome::NOTIFICATION_PRINT_JOB_EVENT,
147 content::Source<PrintJob>(this), 146 content::Source<PrintJob>(this),
148 content::Details<JobEventDetails>(details.get())); 147 content::Details<JobEventDetails>(details.get()));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 document_ = new_document; 324 document_ = new_document;
326 325
327 if (document_.get()) { 326 if (document_.get()) {
328 settings_ = document_->settings(); 327 settings_ = document_->settings();
329 } 328 }
330 329
331 if (worker_) { 330 if (worker_) {
332 DCHECK(!is_job_pending_); 331 DCHECK(!is_job_pending_);
333 // Sync the document with the worker. 332 // Sync the document with the worker.
334 worker_->PostTask(FROM_HERE, 333 worker_->PostTask(FROM_HERE,
335 base::Bind(&HoldRefCallback, 334 base::Bind(&HoldRefCallback, make_scoped_refptr(this),
336 make_scoped_refptr(this),
337 base::Bind(&PrintJobWorker::OnDocumentChanged, 335 base::Bind(&PrintJobWorker::OnDocumentChanged,
338 base::Unretained(worker_.get()), 336 base::Unretained(worker_.get()),
339 document_))); 337 base::RetainedRef(document_))));
340 } 338 }
341 } 339 }
342 340
343 void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) { 341 void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
344 switch (event_details.type()) { 342 switch (event_details.type()) {
345 case JobEventDetails::FAILED: { 343 case JobEventDetails::FAILED: {
346 settings_.Clear(); 344 settings_.Clear();
347 // No need to cancel since the worker already canceled itself. 345 // No need to cancel since the worker already canceled itself.
348 Stop(); 346 Stop();
349 break; 347 break;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 453 }
456 454
457 JobEventDetails::~JobEventDetails() { 455 JobEventDetails::~JobEventDetails() {
458 } 456 }
459 457
460 PrintedDocument* JobEventDetails::document() const { return document_.get(); } 458 PrintedDocument* JobEventDetails::document() const { return document_.get(); }
461 459
462 PrintedPage* JobEventDetails::page() const { return page_.get(); } 460 PrintedPage* JobEventDetails::page() const { return page_.get(); }
463 461
464 } // namespace printing 462 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698