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

Unified Diff: chromeos/printing/printer_detector.h

Issue 2344393002: Add a PrinterDiscoverer fake object. (Closed)
Patch Set: comments addressed Created 4 years, 3 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: chromeos/printing/printer_detector.h
diff --git a/chromeos/printing/printer_detector.h b/chromeos/printing/printer_detector.h
new file mode 100644
index 0000000000000000000000000000000000000000..de51eb3169a3518e3192aa23269cffc3b770560b
--- /dev/null
+++ b/chromeos/printing/printer_detector.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
+#define CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
+
+#include <memory>
+#include <vector>
+
+#include "chromeos/printing/printer_configuration.h"
+
+namespace chromeos {
+
+// Interface for printer discovery. Constructs Printer objects from USB and
+// zeroconf (DNS-SD) printers.
+class PrinterDetector {
+ public:
+ // Interface for objects interested in detected printers.
+ class Observer {
+ public:
+ // Called after discovery has started.
+ virtual void OnDiscoveryStarted() = 0;
+
+ // Called when discovery is stopping. OnPrintersFound will not be
+ // called after this occurs.
+ virtual void OnDiscoverStopping() = 0;
+
+ // Called with a collection of printers as they are discovered.
+ virtual void OnPrintersFound(std::vector<Printer> printers) = 0;
+ };
+
+ // Static factory. Caller is responsible for the created object.
+ static std::unique_ptr<PrinterDetector> Create();
+
+ // Begin scanning for printers. Found printers will be reported to the
+ // attached observer.
+ virtual bool StartDiscovery() = 0;
+
+ // Stop scanning for printers. Returns true if scanning was stopped
+ // successfully. No calls to the attached observer will be made after this
+ // returns if it returned true.
+ virtual bool StopDiscovery() = 0;
+
+ // Add an observer that will be notified of discovered printers.
+ virtual void AddObserver(PrinterDetector::Observer* observer) = 0;
+
+ // Remove an observer of printer discovery.
+ virtual void RemoveObserver(PrinterDetector::Observer* observer) = 0;
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
« chromeos/printing/fake_printer_detector.cc ('K') | « chromeos/printing/fake_printer_detector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698