Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Unified Diff: chrome/browser/chromeos/printing/cups_print_job_manager.cc

Issue 2435303003: [CUPS] Implement the Print Job notification. (Closed)
Patch Set: Bug fix. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/printing/cups_print_job_manager.cc
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager.cc b/chrome/browser/chromeos/printing/cups_print_job_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..82f38658094e78e47af4edf75d79e7b876d4eed4
--- /dev/null
+++ b/chrome/browser/chromeos/printing/cups_print_job_manager.cc
@@ -0,0 +1,40 @@
+// 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_manager.h"
+
+#include <algorithm>
+
+#include "chrome/browser/chromeos/printing/cups_print_job_notification_manager.h"
+
+namespace chromeos {
+
+CUPSPrintJobManager::CUPSPrintJobManager(Profile* profile)
+ : profile_(profile),
+ notification_manager_(new CUPSPrintJobNotificationManager(profile)) {
+ 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.
+}
+
+CUPSPrintJobManager::~CUPSPrintJobManager() {
+ if (notification_manager_)
+ RemoveObserver(notification_manager_.get());
+ print_jobs_.clear();
+ profile_ = nullptr;
+}
+
+void CUPSPrintJobManager::Shutdown() {}
+
+void CUPSPrintJobManager::AddObserver(Observer* observer) {
+ auto found = std::find(observers_.begin(), observers_.end(), observer);
+ if (found == observers_.end())
+ observers_.push_back(observer);
+}
+
+void CUPSPrintJobManager::RemoveObserver(Observer* observer) {
+ auto found = std::find(observers_.begin(), observers_.end(), observer);
+ if (found != observers_.end())
+ observers_.erase(found);
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698