Chromium Code Reviews| Index: chrome/browser/chromeos/printing/cups_print_job_notification_manager.cc |
| diff --git a/chrome/browser/chromeos/printing/cups_print_job_notification_manager.cc b/chrome/browser/chromeos/printing/cups_print_job_notification_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..78513360ffb00075abd86781b5d37941a153eac6 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/printing/cups_print_job_notification_manager.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/printing/cups_print_job_notification_manager.h" |
| + |
| +#include "chrome/browser/chromeos/printing/cups_print_job.h" |
| +#include "chrome/browser/profiles/profile.h" |
| + |
| +namespace chromeos { |
| + |
| +CupsPrintJobNotificationManager::CupsPrintJobNotificationManager( |
| + Profile* profile, |
| + CupsPrintJobManager* print_job_manager) |
| + : print_job_manager_(print_job_manager), profile_(profile) { |
| + if (print_job_manager_) |
| + print_job_manager_->AddObserver(this); |
| +} |
| + |
| +CupsPrintJobNotificationManager::~CupsPrintJobNotificationManager() { |
| + if (print_job_manager_) |
| + print_job_manager_->RemoveObserver(this); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobCreated(CupsPrintJob* job) { |
| + if (notification_map_.find(job) != notification_map_.end()) |
|
skau
2016/10/27 01:43:01
you can use base::ContainsKey() for this. It's a
xdai1
2016/10/28 23:59:54
Done.
|
| + return; |
| + notification_map_[job] = |
| + base::MakeUnique<CupsPrintJobNotification>(job, profile_); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobStarted(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
|
skau
2016/10/27 01:43:01
If we end up extracting all the information from t
xdai1
2016/10/28 23:59:54
I think it's nicer to have different changes other
skau
2016/10/31 15:39:05
Okay. I was wondering if OnPrintJobStatusUpdated(
|
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobUpdated(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobSuspended(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobResumed(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobDone(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
| +} |
| + |
| +void CupsPrintJobNotificationManager::OnPrintJobError(CupsPrintJob* job) { |
| + DCHECK(notification_map_.find(job) != notification_map_.end()); |
| + notification_map_[job]->OnPrintJobStatusUpdated(); |
| +} |
| + |
| +} // namespace chromeos |