OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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" |
11 #include "chrome/common/notification_service.h" | 11 #include "chrome/common/notification_service.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "printing/printed_document.h" | 13 #include "printing/printed_document.h" |
14 #include "printing/printed_page.h" | 14 #include "printing/printed_page.h" |
15 | 15 |
16 namespace printing { | 16 namespace printing { |
17 | 17 |
18 PrintJobManager::PrintJobManager() { | 18 PrintJobManager::PrintJobManager() { |
19 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, | 19 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, |
20 NotificationService::AllSources()); | 20 NotificationService::AllSources()); |
21 } | 21 } |
22 | 22 |
23 PrintJobManager::~PrintJobManager() { | 23 PrintJobManager::~PrintJobManager() { |
24 AutoLock lock(lock_); | 24 base::AutoLock lock(lock_); |
25 queued_queries_.clear(); | 25 queued_queries_.clear(); |
26 } | 26 } |
27 | 27 |
28 void PrintJobManager::OnQuit() { | 28 void PrintJobManager::OnQuit() { |
29 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
30 // OnQuit is too late to try to wait for jobs on the Mac, since the runloop | 30 // OnQuit is too late to try to wait for jobs on the Mac, since the runloop |
31 // has already been torn down; instead, StopJobs(true) is called earlier in | 31 // has already been torn down; instead, StopJobs(true) is called earlier in |
32 // the shutdown process, and this is just here in case something sneaks | 32 // the shutdown process, and this is just here in case something sneaks |
33 // in after that. | 33 // in after that. |
34 StopJobs(false); | 34 StopJobs(false); |
(...skipping 17 matching lines...) Expand all Loading... |
52 // Wait for 120 seconds for the print job to be spooled. | 52 // Wait for 120 seconds for the print job to be spooled. |
53 if (wait_for_finish) | 53 if (wait_for_finish) |
54 job->FlushJob(120000); | 54 job->FlushJob(120000); |
55 job->Stop(); | 55 job->Stop(); |
56 } | 56 } |
57 } | 57 } |
58 current_jobs_.clear(); | 58 current_jobs_.clear(); |
59 } | 59 } |
60 | 60 |
61 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { | 61 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { |
62 AutoLock lock(lock_); | 62 base::AutoLock lock(lock_); |
63 DCHECK(job); | 63 DCHECK(job); |
64 queued_queries_.push_back(make_scoped_refptr(job)); | 64 queued_queries_.push_back(make_scoped_refptr(job)); |
65 DCHECK(job->is_valid()); | 65 DCHECK(job->is_valid()); |
66 } | 66 } |
67 | 67 |
68 void PrintJobManager::PopPrinterQuery(int document_cookie, | 68 void PrintJobManager::PopPrinterQuery(int document_cookie, |
69 scoped_refptr<PrinterQuery>* job) { | 69 scoped_refptr<PrinterQuery>* job) { |
70 AutoLock lock(lock_); | 70 base::AutoLock lock(lock_); |
71 for (PrinterQueries::iterator itr = queued_queries_.begin(); | 71 for (PrinterQueries::iterator itr = queued_queries_.begin(); |
72 itr != queued_queries_.end(); | 72 itr != queued_queries_.end(); |
73 ++itr) { | 73 ++itr) { |
74 PrinterQuery* current_query = *itr; | 74 PrinterQuery* current_query = *itr; |
75 if (current_query->cookie() == document_cookie && | 75 if (current_query->cookie() == document_cookie && |
76 !current_query->is_callback_pending()) { | 76 !current_query->is_callback_pending()) { |
77 *job = current_query; | 77 *job = current_query; |
78 queued_queries_.erase(itr); | 78 queued_queries_.erase(itr); |
79 DCHECK(current_query->is_valid()); | 79 DCHECK(current_query->is_valid()); |
80 return; | 80 return; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 break; | 155 break; |
156 } | 156 } |
157 default: { | 157 default: { |
158 NOTREACHED(); | 158 NOTREACHED(); |
159 break; | 159 break; |
160 } | 160 } |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 bool PrintJobManager::printing_enabled() { | 164 bool PrintJobManager::printing_enabled() { |
165 AutoLock lock(enabled_lock_); | 165 base::AutoLock lock(enabled_lock_); |
166 return printing_enabled_; | 166 return printing_enabled_; |
167 } | 167 } |
168 | 168 |
169 void PrintJobManager::set_printing_enabled(bool printing_enabled) { | 169 void PrintJobManager::set_printing_enabled(bool printing_enabled) { |
170 AutoLock lock(enabled_lock_); | 170 base::AutoLock lock(enabled_lock_); |
171 printing_enabled_ = printing_enabled; | 171 printing_enabled_ = printing_enabled; |
172 } | 172 } |
173 | 173 |
174 } // namespace printing | 174 } // namespace printing |
OLD | NEW |