| 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/service/cloud_print/printer_job_handler.h" | 5 #include "chrome/service/cloud_print/printer_job_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 base::ThreadTaskRunnerHandle::Get()->PostTask( | 234 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 235 FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); | 235 FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 void PrinterJobHandler::OnJobChanged() { | 239 void PrinterJobHandler::OnJobChanged() { |
| 240 // Some job on the printer changed. Loop through all our JobStatusUpdaters | 240 // Some job on the printer changed. Loop through all our JobStatusUpdaters |
| 241 // and have them check for updates. | 241 // and have them check for updates. |
| 242 for (const auto& it : job_status_updater_list_) { | 242 for (const auto& it : job_status_updater_list_) { |
| 243 base::ThreadTaskRunnerHandle::Get()->PostTask( | 243 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 244 FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, it.get())); | 244 FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, it)); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 void PrinterJobHandler::OnJobSpoolSucceeded(const PlatformJobId& job_id) { | 248 void PrinterJobHandler::OnJobSpoolSucceeded(const PlatformJobId& job_id) { |
| 249 DCHECK(CurrentlyOnPrintThread()); | 249 DCHECK(CurrentlyOnPrintThread()); |
| 250 job_spooler_->AddRef(); | 250 job_spooler_->AddRef(); |
| 251 print_thread_.task_runner()->ReleaseSoon(FROM_HERE, job_spooler_.get()); | 251 print_thread_.task_runner()->ReleaseSoon(FROM_HERE, job_spooler_.get()); |
| 252 job_spooler_ = NULL; | 252 job_spooler_ = NULL; |
| 253 job_handler_task_runner_->PostTask( | 253 job_handler_task_runner_->PostTask( |
| 254 FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id)); | 254 FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id)); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 616 |
| 617 // The print job has been spooled locally. We now need to create an object | 617 // The print job has been spooled locally. We now need to create an object |
| 618 // that monitors the status of the job and updates the server. | 618 // that monitors the status of the job and updates the server. |
| 619 scoped_refptr<JobStatusUpdater> job_status_updater( | 619 scoped_refptr<JobStatusUpdater> job_status_updater( |
| 620 new JobStatusUpdater(printer_info_.printer_name, job_details_.job_id_, | 620 new JobStatusUpdater(printer_info_.printer_name, job_details_.job_id_, |
| 621 local_job_id_, cloud_print_server_url_, | 621 local_job_id_, cloud_print_server_url_, |
| 622 print_system_.get(), this)); | 622 print_system_.get(), this)); |
| 623 job_status_updater_list_.push_back(job_status_updater); | 623 job_status_updater_list_.push_back(job_status_updater); |
| 624 base::ThreadTaskRunnerHandle::Get()->PostTask( | 624 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 625 FROM_HERE, | 625 FROM_HERE, |
| 626 base::Bind(&JobStatusUpdater::UpdateStatus, job_status_updater.get())); | 626 base::Bind(&JobStatusUpdater::UpdateStatus, job_status_updater)); |
| 627 | 627 |
| 628 CheckForJobs(kJobFetchReasonQueryMore); | 628 CheckForJobs(kJobFetchReasonQueryMore); |
| 629 | 629 |
| 630 VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" | 630 VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" |
| 631 << ", printer id: " << printer_info_cloud_.printer_id; | 631 << ", printer id: " << printer_info_cloud_.printer_id; |
| 632 base::ThreadTaskRunnerHandle::Get()->PostTask( | 632 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 633 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); | 633 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
| 634 } | 634 } |
| 635 | 635 |
| 636 bool PrinterJobHandler::UpdatePrinterInfo() { | 636 bool PrinterJobHandler::UpdatePrinterInfo() { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 this)) { | 809 this)) { |
| 810 OnJobSpoolFailed(); | 810 OnJobSpoolFailed(); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 bool PrinterJobHandler::CurrentlyOnPrintThread() const { | 814 bool PrinterJobHandler::CurrentlyOnPrintThread() const { |
| 815 return print_thread_.task_runner()->BelongsToCurrentThread(); | 815 return print_thread_.task_runner()->BelongsToCurrentThread(); |
| 816 } | 816 } |
| 817 | 817 |
| 818 } // namespace cloud_print | 818 } // namespace cloud_print |
| OLD | NEW |