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

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

Issue 506163002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/printing/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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_manager.h" 5 #include "chrome/browser/printing/print_job_manager.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/printing/print_job.h" 8 #include "chrome/browser/printing/print_job.h"
9 #include "chrome/browser/printing/printer_query.h" 9 #include "chrome/browser/printing/printer_query.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 return NULL; 49 return NULL;
50 } 50 }
51 51
52 scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery( 52 scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery(
53 int render_process_id, 53 int render_process_id,
54 int render_view_id) { 54 int render_view_id) {
55 scoped_refptr<PrinterQuery> job = 55 scoped_refptr<PrinterQuery> job =
56 new printing::PrinterQuery(render_process_id, render_view_id); 56 new printing::PrinterQuery(render_process_id, render_view_id);
57 base::AutoLock lock(lock_); 57 base::AutoLock lock(lock_);
58 job->SetWorkerDestination(destination_); 58 job->SetWorkerDestination(destination_.get());
59 return job; 59 return job;
60 } 60 }
61 61
62 void PrintQueriesQueue::Shutdown() { 62 void PrintQueriesQueue::Shutdown() {
63 PrinterQueries queries_to_stop; 63 PrinterQueries queries_to_stop;
64 { 64 {
65 base::AutoLock lock(lock_); 65 base::AutoLock lock(lock_);
66 queued_queries_.swap(queries_to_stop); 66 queued_queries_.swap(queries_to_stop);
67 destination_ = NULL; 67 destination_ = NULL;
68 } 68 }
69 // Stop all pending queries, requests to generate print preview do not have 69 // Stop all pending queries, requests to generate print preview do not have
70 // corresponding PrintJob, so any pending preview requests are not covered 70 // corresponding PrintJob, so any pending preview requests are not covered
71 // by PrintJobManager::StopJobs and should be stopped explicitly. 71 // by PrintJobManager::StopJobs and should be stopped explicitly.
72 for (PrinterQueries::iterator itr = queries_to_stop.begin(); 72 for (PrinterQueries::iterator itr = queries_to_stop.begin();
73 itr != queries_to_stop.end(); ++itr) { 73 itr != queries_to_stop.end(); ++itr) {
74 (*itr)->PostTask(FROM_HERE, base::Bind(&PrinterQuery::StopWorker, *itr)); 74 (*itr)->PostTask(FROM_HERE, base::Bind(&PrinterQuery::StopWorker, *itr));
75 } 75 }
76 } 76 }
77 77
78 PrintJobManager::PrintJobManager() : is_shutdown_(false) { 78 PrintJobManager::PrintJobManager() : is_shutdown_(false) {
79 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, 79 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
80 content::NotificationService::AllSources()); 80 content::NotificationService::AllSources());
81 } 81 }
82 82
83 PrintJobManager::~PrintJobManager() { 83 PrintJobManager::~PrintJobManager() {
84 } 84 }
85 85
86 scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() { 86 scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() {
87 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 87 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
88 if (!queue_) 88 if (!queue_.get())
89 queue_ = new PrintQueriesQueue(); 89 queue_ = new PrintQueriesQueue();
90 return queue_; 90 return queue_;
91 } 91 }
92 92
93 void PrintJobManager::Shutdown() { 93 void PrintJobManager::Shutdown() {
94 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 94 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
95 DCHECK(!is_shutdown_); 95 DCHECK(!is_shutdown_);
96 is_shutdown_ = true; 96 is_shutdown_ = true;
97 registrar_.RemoveAll(); 97 registrar_.RemoveAll();
98 StopJobs(true); 98 StopJobs(true);
99 if (queue_) 99 if (queue_.get())
100 queue_->Shutdown(); 100 queue_->Shutdown();
101 queue_ = NULL; 101 queue_ = NULL;
102 } 102 }
103 103
104 void PrintJobManager::StopJobs(bool wait_for_finish) { 104 void PrintJobManager::StopJobs(bool wait_for_finish) {
105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
106 // Copy the array since it can be modified in transit. 106 // Copy the array since it can be modified in transit.
107 PrintJobs to_stop; 107 PrintJobs to_stop;
108 to_stop.swap(current_jobs_); 108 to_stop.swap(current_jobs_);
109 109
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 break; 163 break;
164 } 164 }
165 default: { 165 default: {
166 NOTREACHED(); 166 NOTREACHED();
167 break; 167 break;
168 } 168 }
169 } 169 }
170 } 170 }
171 171
172 } // namespace printing 172 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_job_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698