Chromium Code Reviews| Index: chrome/service/cloud_print/print_system_cups.cc |
| diff --git a/chrome/service/cloud_print/print_system_cups.cc b/chrome/service/cloud_print/print_system_cups.cc |
| index e7fe1f8a3de7b558319ddfe252a1bea18a3bd931..280956159f708035c7c2ebc6f5c390852f6bd5c2 100644 |
| --- a/chrome/service/cloud_print/print_system_cups.cc |
| +++ b/chrome/service/cloud_print/print_system_cups.cc |
| @@ -240,8 +240,8 @@ class PrinterWatcherCUPS |
| PrinterWatcherCUPS(PrintSystemCUPS* print_system, |
| const std::string& printer_name) |
| : printer_name_(printer_name), |
| - delegate_(NULL), |
| - print_system_(print_system) { |
| + delegate_(NULL), |
|
Albert Bodenhamer
2012/03/13 23:57:39
why is this changed?
Vitaly Buka (NO REVIEWS)
2012/03/14 00:11:20
It was attempt to fix style, but still incorrectly
|
| + print_system_(print_system) { |
| } |
| ~PrinterWatcherCUPS() { |
| @@ -251,6 +251,10 @@ class PrinterWatcherCUPS |
| // PrintSystem::PrinterWatcher implementation. |
| virtual bool StartWatching( |
| PrintSystem::PrinterWatcher::Delegate* delegate) OVERRIDE{ |
| + scoped_refptr<printing::PrintBackend> print_backend( |
| + printing::PrintBackend::CreateInstance(NULL)); |
| + child_process_logging::ScopedPrinterInfoSetter prn_info( |
| + print_backend->GetPrinterDriverInfo(printer_name)); |
| if (delegate_ != NULL) |
| StopWatching(); |
| delegate_ = delegate; |
| @@ -279,42 +283,6 @@ class PrinterWatcherCUPS |
| return print_system_->GetPrinterInfo(printer_name_, printer_info); |
| } |
| - void JobStatusUpdate() { |
| - if (delegate_ == NULL) |
| - return; // Orphan call. We have been stopped already. |
| - // For CUPS proxy, we are going to fire OnJobChanged notification |
| - // periodically. Higher level will check if there are any outstanding |
| - // jobs for this printer and check their status. If printer has no |
| - // outstanding jobs, OnJobChanged() will do nothing. |
| - delegate_->OnJobChanged(); |
| - MessageLoop::current()->PostDelayedTask( |
| - FROM_HERE, |
| - base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), |
| - base::TimeDelta::FromSeconds(kJobUpdateTimeoutSeconds)); |
| - } |
| - |
| - void PrinterUpdate() { |
| - if (delegate_ == NULL) |
| - return; // Orphan call. We have been stopped already. |
| - VLOG(1) << "CP_CUPS: Checking for printer updates: " << printer_name_; |
| - if (print_system_->NotifyDelete() && |
| - !print_system_->IsValidPrinter(printer_name_)) { |
| - delegate_->OnPrinterDeleted(); |
| - VLOG(1) << "CP_CUPS: Printer deleted: " << printer_name_; |
| - } else { |
| - std::string new_hash = GetSettingsHash(); |
| - if (settings_hash_ != new_hash) { |
| - settings_hash_ = new_hash; |
| - delegate_->OnPrinterChanged(); |
| - VLOG(1) << "CP_CUPS: Printer update detected for: " << printer_name_; |
| - } |
| - } |
| - MessageLoop::current()->PostDelayedTask( |
| - FROM_HERE, |
| - base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), |
| - print_system_->GetUpdateTimeout()); |
| - } |
| - |
| private: |
| std::string GetSettingsHash() { |
| printing::PrinterBasicInfo info; |
| @@ -340,7 +308,6 @@ class PrinterWatcherCUPS |
| return base::MD5String(to_hash); |
| } |
| - |
| std::string printer_name_; |
| PrintSystem::PrinterWatcher::Delegate* delegate_; |
| scoped_refptr<PrintSystemCUPS> print_system_; |
| @@ -512,8 +479,9 @@ bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, |
| } |
| // Print ticket on linux is a JSON string containing only one dictionary. |
| -bool PrintSystemCUPS::ParsePrintTicket(const std::string& print_ticket, |
| - std::map<std::string, std::string>* options) { |
| +bool PrintSystemCUPS::ParsePrintTicket( |
| + const std::string& print_ticket, |
| + std::map<std::string, std::string>* options) { |
| DCHECK(options); |
| scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket, false)); |
| if (ticket_value == NULL || !ticket_value->IsType(Value::TYPE_DICTIONARY)) |
| @@ -552,6 +520,7 @@ bool PrintSystemCUPS::GetPrinterCapsAndDefaults( |
| } |
| // TODO(gene): Retry multiple times in case of error. |
| + child_process_logging::ScopedPrinterInfoSetter prn_info(server_info->backend->GetPrinterDriverInfo()); |
|
Albert Bodenhamer
2012/03/13 23:57:39
80 chars
Vitaly Buka (NO REVIEWS)
2012/03/14 00:11:20
Done.
|
| if (!server_info->backend->GetPrinterCapsAndDefaults(short_printer_name, |
| printer_info) ) { |
| return false; |
| @@ -573,6 +542,8 @@ bool PrintSystemCUPS::GetJobDetails(const std::string& printer_name, |
| if (!server_info) |
| return false; |
| + child_process_logging::ScopedPrinterInfoSetter prn_info( |
| + server_info->backend->GetPrinterDriverInfo()); |
| cups_job_t* jobs = NULL; |
| int num_jobs = GetJobs(&jobs, server_info->url, |
| short_printer_name.c_str(), 1, -1); |
| @@ -738,6 +709,9 @@ PlatformJobId PrintSystemCUPS::SpoolPrintJob( |
| if (!server_info) |
| return false; |
| + child_process_logging::ScopedPrinterInfoSetter prn_info( |
| + server_info->backend->GetPrinterDriverInfo(printer_name)); |
| + |
| // We need to store options as char* string for the duration of the |
| // cupsPrintFile2 call. We'll use map here to store options, since |
| // Dictionary value from JSON parser returns wchat_t. |