OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 // Interface for objects interested in detected printers. | 22 // Interface for objects interested in detected printers. |
23 class Observer { | 23 class Observer { |
24 public: | 24 public: |
25 virtual ~Observer() = default; | 25 virtual ~Observer() = default; |
26 | 26 |
27 // Called when we are done with the initial scan for printers. We may | 27 // Called when we are done with the initial scan for printers. We may |
28 // still call OnPrintersFound if the set of available printers | 28 // still call OnPrintersFound if the set of available printers |
29 // changes, but the user can conclude that if a printer is currently | 29 // changes, but the user can conclude that if a printer is currently |
30 // available and not in the list, we're not still looking for it. | 30 // available and not in the list, we're not still looking for it. |
31 virtual void OnDiscoveryInitialScanDone() = 0; | 31 // TODO(justincarlson): Merge with OnPrintersFound when crbug.com/588234 is |
| 32 // complete. |
| 33 virtual void OnDiscoveryInitialScanDone(int printer_count) = 0; |
32 | 34 |
33 // Called with a collection of printers as they are discovered. On each | 35 // Called with a collection of printers as they are discovered. On each |
34 // call |printers| is the full set of known printers; it is not | 36 // call |printers| is the full set of known printers; it is not |
35 // incremental; printers may be added or removed. | 37 // incremental; printers may be added or removed. |
36 // | 38 // |
37 // Observers will get an OnPrintersFound callback after registration | 39 // Observers will get an OnPrintersFound callback after registration |
38 // with the existing list of printers (which may be empty) and will get | 40 // with the existing list of printers (which may be empty) and will get |
39 // additional calls whenever the set of printers changes. | 41 // additional calls whenever the set of printers changes. |
40 virtual void OnPrintersFound(const std::vector<Printer>& printers) = 0; | 42 virtual void OnPrintersFound(const std::vector<Printer>& printers) = 0; |
41 }; | 43 }; |
42 | 44 |
43 // Static factory | 45 // Static factory |
44 static std::unique_ptr<PrinterDiscoverer> CreateForProfile(Profile* profile); | 46 static std::unique_ptr<PrinterDiscoverer> CreateForProfile(Profile* profile); |
45 | 47 |
46 virtual ~PrinterDiscoverer() = default; | 48 virtual ~PrinterDiscoverer() = default; |
47 | 49 |
48 // Add an observer that will be notified of discovered printers. Ownership of | 50 // 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 | 51 // |observer| is not taken by the discoverer. It is an error to add an |
50 // observer more than once. Calls to |observer| methods will take place on | 52 // observer more than once. Calls to |observer| methods will take place on |
51 // the thread PrinterDiscoverer was instantiated on. | 53 // the thread PrinterDiscoverer was instantiated on. |
52 virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; | 54 virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; |
53 | 55 |
54 // Remove an observer of printer discovery. | 56 // Remove an observer of printer discovery. |
55 virtual void RemoveObserver(PrinterDiscoverer::Observer* observer) = 0; | 57 virtual void RemoveObserver(PrinterDiscoverer::Observer* observer) = 0; |
56 }; | 58 }; |
57 | 59 |
58 } // namespace chromeos | 60 } // namespace chromeos |
59 | 61 |
60 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ | 62 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
OLD | NEW |