Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/printing/print_job.h" | 9 #include "chrome/browser/printing/print_job.h" |
| 10 #include "chrome/browser/printing/printer_query.h" | 10 #include "chrome/browser/printing/printer_query.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 current_jobs_.clear(); | 64 current_jobs_.clear(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { | 67 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { |
| 68 base::AutoLock lock(lock_); | 68 base::AutoLock lock(lock_); |
| 69 DCHECK(job); | 69 DCHECK(job); |
| 70 queued_queries_.push_back(make_scoped_refptr(job)); | 70 queued_queries_.push_back(make_scoped_refptr(job)); |
| 71 DCHECK(job->is_valid()); | 71 DCHECK(job->is_valid()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void PrintJobManager::PopAndStopPrinterQuery(int document_cookie) { | |
| 75 // Shamelessly ripped from PrintViewManager to clean up the print worker. | |
|
cbentzel
2011/05/13 15:35:33
This comment is likely not needed anymore.
dominich
2011/05/13 16:25:08
Done.
| |
| 76 scoped_refptr<PrinterQuery> printer_query; | |
| 77 PopPrinterQuery(document_cookie, &printer_query); | |
| 78 if (printer_query.get()) { | |
| 79 BrowserThread::PostTask( | |
| 80 BrowserThread::IO, FROM_HERE, | |
| 81 NewRunnableMethod(printer_query.get(), | |
| 82 &PrinterQuery::StopWorker)); | |
| 83 } | |
| 84 } | |
| 85 | |
| 74 void PrintJobManager::PopPrinterQuery(int document_cookie, | 86 void PrintJobManager::PopPrinterQuery(int document_cookie, |
| 75 scoped_refptr<PrinterQuery>* job) { | 87 scoped_refptr<PrinterQuery>* job) { |
| 76 base::AutoLock lock(lock_); | 88 base::AutoLock lock(lock_); |
| 77 for (PrinterQueries::iterator itr = queued_queries_.begin(); | 89 for (PrinterQueries::iterator itr = queued_queries_.begin(); |
| 78 itr != queued_queries_.end(); | 90 itr != queued_queries_.end(); |
| 79 ++itr) { | 91 ++itr) { |
| 80 PrinterQuery* current_query = *itr; | 92 PrinterQuery* current_query = *itr; |
| 81 if (current_query->cookie() == document_cookie && | 93 if (current_query->cookie() == document_cookie && |
| 82 !current_query->is_callback_pending()) { | 94 !current_query->is_callback_pending()) { |
| 83 *job = current_query; | 95 *job = current_query; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 break; | 169 break; |
| 158 } | 170 } |
| 159 default: { | 171 default: { |
| 160 NOTREACHED(); | 172 NOTREACHED(); |
| 161 break; | 173 break; |
| 162 } | 174 } |
| 163 } | 175 } |
| 164 } | 176 } |
| 165 | 177 |
| 166 } // namespace printing | 178 } // namespace printing |
| OLD | NEW |