| 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 // Stop all pending queries, requests to generate print preview do not have |
| 67 // corresponding PrintJob, so any pending preview requests are not covered |
| 68 // by PrintJobManager::StopJobs and should be stopped explicitly. |
| 69 for (PrinterQueries::iterator itr = queries_to_stop.begin(); |
| 70 itr != queries_to_stop.end(); ++itr) { |
| 71 (*itr)->message_loop()->PostTask( |
| 72 FROM_HERE, base::Bind(&PrinterQuery::StopWorker, *itr)); |
| 73 } |
| 63 } | 74 } |
| 64 | 75 |
| 65 PrintJobManager::PrintJobManager() : is_shutdown_(false) { | 76 PrintJobManager::PrintJobManager() : is_shutdown_(false) { |
| 66 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, | 77 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
| 67 content::NotificationService::AllSources()); | 78 content::NotificationService::AllSources()); |
| 68 } | 79 } |
| 69 | 80 |
| 70 PrintJobManager::~PrintJobManager() { | 81 PrintJobManager::~PrintJobManager() { |
| 71 } | 82 } |
| 72 | 83 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 break; | 161 break; |
| 151 } | 162 } |
| 152 default: { | 163 default: { |
| 153 NOTREACHED(); | 164 NOTREACHED(); |
| 154 break; | 165 break; |
| 155 } | 166 } |
| 156 } | 167 } |
| 157 } | 168 } |
| 158 | 169 |
| 159 } // namespace printing | 170 } // namespace printing |
| OLD | NEW |