Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/printing/cups_print_job_manager.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "chrome/browser/chromeos/printing/cups_print_job_notification_manager.h " | |
| 10 | |
| 11 namespace chromeos { | |
| 12 | |
| 13 CUPSPrintJobManager::CUPSPrintJobManager(Profile* profile) | |
| 14 : profile_(profile), | |
| 15 notification_manager_(new CUPSPrintJobNotificationManager(profile)) { | |
| 16 AddObserver(notification_manager_.get()); | |
|
stevenjb
2016/10/26 19:59:58
This is a bit backwards. Generally we would pass |
xdai1
2016/10/26 22:55:19
I see. Modified as you suggested.
| |
| 17 } | |
| 18 | |
| 19 CUPSPrintJobManager::~CUPSPrintJobManager() { | |
| 20 if (notification_manager_) | |
| 21 RemoveObserver(notification_manager_.get()); | |
| 22 print_jobs_.clear(); | |
| 23 profile_ = nullptr; | |
| 24 } | |
| 25 | |
| 26 void CUPSPrintJobManager::Shutdown() {} | |
| 27 | |
| 28 void CUPSPrintJobManager::AddObserver(Observer* observer) { | |
| 29 auto found = std::find(observers_.begin(), observers_.end(), observer); | |
| 30 if (found == observers_.end()) | |
| 31 observers_.push_back(observer); | |
| 32 } | |
| 33 | |
| 34 void CUPSPrintJobManager::RemoveObserver(Observer* observer) { | |
| 35 auto found = std::find(observers_.begin(), observers_.end(), observer); | |
| 36 if (found != observers_.end()) | |
| 37 observers_.erase(found); | |
| 38 } | |
| 39 | |
| 40 } // namespace chromeos | |
| OLD | NEW |