Chromium Code Reviews| Index: chromeos/printing/printer_discoverer.h |
| diff --git a/chromeos/printing/printer_discoverer.h b/chromeos/printing/printer_discoverer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..71bdec486e1b59f4dc9783f4ffee2c0718a3d90d |
| --- /dev/null |
| +++ b/chromeos/printing/printer_discoverer.h |
| @@ -0,0 +1,59 @@ |
| +// 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_DISCOVERER_H_ |
| +#define CHROMEOS_PRINTING_PRINTER_DISCOVERER_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 PrinterDiscoverer { |
| + public: |
| + // Interface for objects interested in detected printers. |
| + class Observer { |
| + public: |
| + // Called after discovery has started. |
| + virtual void OnDiscoveryStarted() = 0; |
|
xdai1
2016/10/03 23:34:38
Better to not make it pure virtual? Because in the
skau
2016/10/03 23:52:30
Done.
|
| + |
| + // 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. Printer |
| + // objects must be copied if they are retained outside of the scope of this |
| + // function. |
| + virtual void OnPrintersFound(const std::vector<Printer>& printers) = 0; |
|
xdai1
2016/10/03 23:34:38
Add a "virtual void OnDiscoveryDone() {}" function
skau
2016/10/03 23:52:30
Done.
|
| + }; |
| + |
| + // Static factory |
| + static std::unique_ptr<PrinterDiscoverer> Create(); |
| + |
| + // Begin scanning for printers. Found printers will be reported to the |
| + // attached observer. |
| + virtual bool StartDiscovery() = 0; |
| + |
| + // Stop scanning for printers. Returns false if scanning could not be stopped |
| + // and new results will continue to be be sent to observers. 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. Ownership of |
| + // |observer| is not taken by the discoverer. It is an error to add an |
| + // oberserver more than once. |
| + virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; |
| + |
| + // Remove an observer of printer discovery. |
| + virtual void RemoveObserver(PrinterDiscoverer::Observer* observer) = 0; |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |