Chromium Code Reviews| 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; |
|
Carlson
2016/10/03 18:00:51
Should this passed vector be a const reference?
skau
2016/10/03 22:57:27
yes.
|
| + }; |
| + |
| + // Static factory. Caller is responsible for the created object. |
|
Carlson
2016/10/03 18:00:51
"Caller is responsible" comment is not really need
skau
2016/10/03 22:57:27
Done.
|
| + 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. |
|
Carlson
2016/10/03 18:00:51
What should I expect if it returns false?
skau
2016/10/03 22:57:27
Done.
|
| + virtual bool StopDiscovery() = 0; |
| + |
| + // Add an observer that will be notified of discovered printers. |
|
Carlson
2016/10/03 18:00:51
Add ownership (not taken) note.
Probably also wor
skau
2016/10/03 22:57:27
Done.
|
| + 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_ |