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 #ifndef CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | |
| 6 #define CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "chromeos/printing/printer_configuration.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 | |
| 15 // Interface for printer discovery. Constructs Printer objects from USB and | |
| 16 // zeroconf (DNS-SD) printers. | |
| 17 class PrinterDiscoverer { | |
| 18 public: | |
| 19 // Interface for objects interested in detected printers. | |
| 20 class Observer { | |
| 21 public: | |
| 22 // Called after discovery has started. | |
| 23 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.
| |
| 24 | |
| 25 // Called when discovery is stopping. OnPrintersFound will not be | |
| 26 // called after this occurs. | |
| 27 virtual void OnDiscoverStopping() = 0; | |
| 28 | |
| 29 // Called with a collection of printers as they are discovered. Printer | |
| 30 // objects must be copied if they are retained outside of the scope of this | |
| 31 // function. | |
| 32 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.
| |
| 33 }; | |
| 34 | |
| 35 // Static factory | |
| 36 static std::unique_ptr<PrinterDiscoverer> Create(); | |
| 37 | |
| 38 // Begin scanning for printers. Found printers will be reported to the | |
| 39 // attached observer. | |
| 40 virtual bool StartDiscovery() = 0; | |
| 41 | |
| 42 // Stop scanning for printers. Returns false if scanning could not be stopped | |
| 43 // and new results will continue to be be sent to observers. Returns true if | |
| 44 // scanning was stopped successfully. No calls to the attached observer will | |
| 45 // be made after this returns if it returned true. | |
| 46 virtual bool StopDiscovery() = 0; | |
| 47 | |
| 48 // Add an observer that will be notified of discovered printers. Ownership of | |
| 49 // |observer| is not taken by the discoverer. It is an error to add an | |
| 50 // oberserver more than once. | |
| 51 virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; | |
| 52 | |
| 53 // Remove an observer of printer discovery. | |
| 54 virtual void RemoveObserver(PrinterDiscoverer::Observer* observer) = 0; | |
| 55 }; | |
| 56 | |
| 57 } // namespace chromeos | |
| 58 | |
| 59 #endif // CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | |
| OLD | NEW |