Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/chromeos/printing/printer_detector.h

Issue 2945303005: Refactor PrinterDiscoverer and PrinterDetector to use a common interface. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
7
8 #include <vector>
9
10 #include "chromeos/printing/printer_configuration.h"
11
12 namespace chromeos {
13
14 // Interface for automatic printer detection. This API allows for
15 // incremental discovery of printers and notification when discovery
16 // is complete.
17 //
18 // All of the interface calls in this class must be called from the
19 // same sequence, but do not have to be on any specific thread.
20 //
21 // The usual usage of this interface by a class that wants to maintain
22 // an up-to-date list of the printers detected is this:
23 //
24 // auto detector_ = PrinterDetectorImplementation::Create();
25 // detector_->AddObserver(this);
26 // printers_ = detector_->GetPrinters();
27 //
28 class CHROMEOS_EXPORT PrinterDetector {
29 public:
30 class Observer {
31 public:
32 virtual ~Observer() = default;
33
34 // Called with a collection of printers as they are discovered. On each
35 // call |printers| is the full set of known printers; it is not
36 // incremental; printers may be added or removed.
37 virtual void OnPrintersFound(const std::vector<Printer>& printers) = 0;
38
39 // Called when we are done with the initial scan for printers. We may
40 // still call OnPrintersFound if the set of available printers
41 // changes, but the user can conclude that if a printer is currently
42 // available and not in the list, we're not still looking for it.
43 virtual void OnPrinterScanComplete() = 0;
44 };
45
46 virtual ~PrinterDetector() = default;
47
48 // Start scanning for printers. No observer callbacks will be performed
49 // until this is called.
50 virtual void Start() = 0;
51
52 // Observer management. Observer callbacks will be performed on the
53 // calling sequence.
54 virtual void AddObserver(Observer* observer) = 0;
55 virtual void RemoveObserver(Observer* observer) = 0;
56
57 // Get the current list of known printers.
58 virtual std::vector<Printer> GetPrinters() = 0;
59 };
60
61 } // namespace chromeos
62
63 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTER_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698