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_DETECTOR_H_ | |
| 6 #define CHROMEOS_PRINTING_PRINTER_DETECTOR_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 PrinterDetector { | |
| 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; | |
| 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. | |
| 30 virtual void OnPrintersFound(std::vector<Printer> printers) = 0; | |
| 31 }; | |
| 32 | |
| 33 // Static factory. Caller is responsible for the created object. | |
| 34 static std::unique_ptr<PrinterDetector> Create(); | |
| 35 | |
| 36 // Begin scanning for printers. Found printers will be reported to the | |
| 37 // attachd observer. | |
|
xdai1
2016/09/19 18:56:10
nit: attached
skau
2016/09/20 01:56:47
Done.
| |
| 38 virtual bool StartDiscovery() = 0; | |
| 39 | |
| 40 // Stop scanning for printers. Returns true if scanning was stopped | |
| 41 // successfully. No calls to the attached observer will be made after this | |
| 42 // returns if it returned true. | |
| 43 virtual bool StopDiscovery() = 0; | |
| 44 | |
| 45 // Set an observer that will be notified of discovered printers. | |
| 46 virtual void SetObserver(PrinterDetector::Observer* observer) = 0; | |
|
xdai1
2016/09/19 18:56:10
How about maintaining a list of observers and then
skau
2016/09/20 01:56:47
Done.
| |
| 47 }; | |
| 48 | |
| 49 } // namespace chromeos | |
| 50 | |
| 51 #endif // CHROMEOS_PRINTING_PRINTER_DETECTOR_H_ | |
| OLD | NEW |