Chromium Code Reviews| Index: chrome/browser/chromeos/printing/printer_discoverer.h |
| diff --git a/chrome/browser/chromeos/printing/printer_discoverer.h b/chrome/browser/chromeos/printing/printer_discoverer.h |
| index b0a863900872896998b4bbf422fb102b250a7fc3..67fa0e96c8d2fba71900eae0375ae0aa73480f6c 100644 |
| --- a/chrome/browser/chromeos/printing/printer_discoverer.h |
| +++ b/chrome/browser/chromeos/printing/printer_discoverer.h |
| @@ -10,50 +10,45 @@ |
| #include "chromeos/printing/printer_configuration.h" |
| +class Profile; |
| + |
| namespace chromeos { |
| // Interface for printer discovery. Constructs Printer objects from USB and |
| -// zeroconf (DNS-SD) printers. |
| +// zeroconf (DNS-SD) printers. All functions in this class must be called |
| +// from a sequenced context. |
| class CHROMEOS_EXPORT PrinterDiscoverer { |
| public: |
| // Interface for objects interested in detected printers. |
| class Observer { |
| public: |
| - // Called after discovery has started. |
| - virtual void OnDiscoveryStarted() {} |
| - |
| - // Called when discovery is stopping. OnPrintersFound will not be |
| - // called after this occurs. |
| - virtual void OnDiscoveryStopping() {} |
| - |
| - // Called after all printers have been discovered and the observers |
| - // notified. |
| - virtual void OnDiscoveryDone() {} |
| - |
| - // 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) {} |
| + virtual ~Observer() = default; |
| + |
| + // Called when we are done with the initial scan for printers. We may |
| + // still call OnPrintersFound if the set of available printers |
| + // changes, but the user can conclude that if a printer is currently |
| + // available and not in the list, we're not still looking for it. |
| + virtual void OnDiscoveryInitialScanDone() = 0; |
| + |
| + // Called with a collection of printers as they are discovered. On each |
| + // call |printers| is the full set of known printers; it is not |
| + // incremental; printers may be added or removed. |
| + // |
| + // Observers will get an OnPrintersFound callback after registration |
| + // with the existing list of printers (which may be empty) and will get |
| + // additional calls whenever the set of printers changes. |
| + virtual void OnPrintersFound(const std::vector<Printer>& printers) = 0; |
| }; |
| // Static factory |
| - static std::unique_ptr<PrinterDiscoverer> Create(); |
| - |
| - virtual ~PrinterDiscoverer() {} |
| - |
| - // Begin scanning for printers. Found printers will be reported to the |
| - // attached observer. |
| - virtual bool StartDiscovery() = 0; |
| + static std::unique_ptr<PrinterDiscoverer> Create(Profile* profile); |
|
stevenjb
2017/04/10 19:49:55
Maybe rename this CreateForProfile for clarity?
Carlson
2017/04/10 22:16:42
Done.
|
| - // 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; |
| + virtual ~PrinterDiscoverer() = default; |
| // 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. |
| + // oberserver more than once. Callbacks to the observer will take place |
|
stevenjb
2017/04/10 19:49:55
nit: 'Calls to |observer| methods'
Carlson
2017/04/10 22:16:42
Done.
|
| + // on the thread PrinterDiscoverer was instantiated on. |
| virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; |
| // Remove an observer of printer discovery. |