| 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/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.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 "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 continue; | 52 continue; |
| 53 // Wait for two minutes for the print job to be spooled. | 53 // Wait for two minutes for the print job to be spooled. |
| 54 if (wait_for_finish) | 54 if (wait_for_finish) |
| 55 job->FlushJob(base::TimeDelta::FromMinutes(2)); | 55 job->FlushJob(base::TimeDelta::FromMinutes(2)); |
| 56 job->Stop(); | 56 job->Stop(); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 current_jobs_.clear(); | 59 current_jobs_.clear(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void PrintJobManager::SetPrintDestination( |
| 63 PrintDestinationInterface* destination) { |
| 64 destination_ = destination; |
| 65 } |
| 66 |
| 62 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { | 67 void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) { |
| 63 base::AutoLock lock(lock_); | 68 base::AutoLock lock(lock_); |
| 64 DCHECK(job); | 69 DCHECK(job); |
| 65 queued_queries_.push_back(make_scoped_refptr(job)); | 70 queued_queries_.push_back(make_scoped_refptr(job)); |
| 66 DCHECK(job->is_valid()); | 71 DCHECK(job->is_valid()); |
| 67 } | 72 } |
| 68 | 73 |
| 69 void PrintJobManager::PopPrinterQuery(int document_cookie, | 74 void PrintJobManager::PopPrinterQuery(int document_cookie, |
| 70 scoped_refptr<PrinterQuery>* job) { | 75 scoped_refptr<PrinterQuery>* job) { |
| 71 base::AutoLock lock(lock_); | 76 base::AutoLock lock(lock_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 123 } |
| 119 case JobEventDetails::JOB_DONE: { | 124 case JobEventDetails::JOB_DONE: { |
| 120 PrintJobs::iterator itr = std::find(current_jobs_.begin(), | 125 PrintJobs::iterator itr = std::find(current_jobs_.begin(), |
| 121 current_jobs_.end(), | 126 current_jobs_.end(), |
| 122 print_job); | 127 print_job); |
| 123 DCHECK(current_jobs_.end() != itr); | 128 DCHECK(current_jobs_.end() != itr); |
| 124 current_jobs_.erase(itr); | 129 current_jobs_.erase(itr); |
| 125 DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(), | 130 DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(), |
| 126 current_jobs_.end(), | 131 current_jobs_.end(), |
| 127 print_job)); | 132 print_job)); |
| 133 destination_ = NULL; |
| 128 break; | 134 break; |
| 129 } | 135 } |
| 130 case JobEventDetails::FAILED: { | 136 case JobEventDetails::FAILED: { |
| 131 PrintJobs::iterator itr = std::find(current_jobs_.begin(), | 137 PrintJobs::iterator itr = std::find(current_jobs_.begin(), |
| 132 current_jobs_.end(), | 138 current_jobs_.end(), |
| 133 print_job); | 139 print_job); |
| 134 // A failed job may have never started. | 140 // A failed job may have never started. |
| 135 if (current_jobs_.end() != itr) { | 141 if (current_jobs_.end() != itr) { |
| 136 current_jobs_.erase(itr); | 142 current_jobs_.erase(itr); |
| 137 DCHECK(current_jobs_.end() == | 143 DCHECK(current_jobs_.end() == |
| (...skipping 18 matching lines...) Expand all Loading... |
| 156 break; | 162 break; |
| 157 } | 163 } |
| 158 } | 164 } |
| 159 } | 165 } |
| 160 | 166 |
| 161 bool PrintJobManager::printing_enabled() const { | 167 bool PrintJobManager::printing_enabled() const { |
| 162 return *printing_enabled_; | 168 return *printing_enabled_; |
| 163 } | 169 } |
| 164 | 170 |
| 165 } // namespace printing | 171 } // namespace printing |
| OLD | NEW |