OLD | NEW |
---|---|
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 } | 50 } |
51 | 51 |
52 scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery() { | 52 scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery() { |
53 scoped_refptr<PrinterQuery> job = new printing::PrinterQuery; | 53 scoped_refptr<PrinterQuery> job = new printing::PrinterQuery; |
54 base::AutoLock lock(lock_); | 54 base::AutoLock lock(lock_); |
55 job->SetWorkerDestination(destination_); | 55 job->SetWorkerDestination(destination_); |
56 return job; | 56 return job; |
57 } | 57 } |
58 | 58 |
59 void PrintQueriesQueue::Shutdown() { | 59 void PrintQueriesQueue::Shutdown() { |
60 base::AutoLock lock(lock_); | 60 PrinterQueries queries_to_stop; |
61 queued_queries_.clear(); | 61 { |
62 destination_ = NULL; | 62 base::AutoLock lock(lock_); |
63 queued_queries_.swap(queries_to_stop); | |
64 destination_ = NULL; | |
65 } | |
66 for (PrinterQueries::iterator itr = queries_to_stop.begin(); | |
67 itr != queries_to_stop.end(); ++itr) { | |
Vitaly Buka (NO REVIEWS)
2014/05/29 00:58:34
iterating using for (size_t i = 0) is shorter
| |
68 scoped_refptr<printing::PrinterQuery> query_to_stop(*itr); | |
Vitaly Buka (NO REVIEWS)
2014/05/29 00:58:34
you don't need temp var query_to_stop
| |
69 query_to_stop->message_loop()->PostTask( | |
70 FROM_HERE, base::Bind(&PrinterQuery::StopWorker, query_to_stop)); | |
71 } | |
63 } | 72 } |
64 | 73 |
65 PrintJobManager::PrintJobManager() : is_shutdown_(false) { | 74 PrintJobManager::PrintJobManager() : is_shutdown_(false) { |
66 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, | 75 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
67 content::NotificationService::AllSources()); | 76 content::NotificationService::AllSources()); |
68 } | 77 } |
69 | 78 |
70 PrintJobManager::~PrintJobManager() { | 79 PrintJobManager::~PrintJobManager() { |
71 } | 80 } |
72 | 81 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 break; | 159 break; |
151 } | 160 } |
152 default: { | 161 default: { |
153 NOTREACHED(); | 162 NOTREACHED(); |
154 break; | 163 break; |
155 } | 164 } |
156 } | 165 } |
157 } | 166 } |
158 | 167 |
159 } // namespace printing | 168 } // namespace printing |
OLD | NEW |