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

Side by Side Diff: device/u2f/u2f_enumerate.h

Issue 2763413008: Add U2F device enumeration class (Closed)
Patch Set: Fix issues causing crash Created 3 years, 8 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
« no previous file with comments | « device/u2f/u2f_device.h ('k') | device/u2f/u2f_enumerate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DEVICE_U2F_U2F_ENUMERATE_H_
6 #define DEVICE_U2F_U2F_ENUMERATE_H_
7
8 #include <list>
9
10 #include "base/scoped_observer.h"
11 #include "device/hid/hid_device_filter.h"
12 #include "device/hid/hid_service.h"
13
14 namespace device {
15 class U2fDevice;
16
17 class U2fEnumerate : HidService::Observer {
18 public:
19 using U2fEnumerateCallback =
20 base::OnceCallback<void(std::list<std::unique_ptr<U2fDevice>>)>;
21 using U2fDeviceAddedCallback =
22 base::RepeatingCallback<void(std::unique_ptr<U2fDevice>)>;
23 using U2fDeviceRemovedCallback =
24 base::RepeatingCallback<void(std::unique_ptr<U2fDevice>)>;
25
26 U2fEnumerate();
27 ~U2fEnumerate();
28
29 void EnumerateU2fDevices(U2fEnumerateCallback enumerate_cb);
30 void set_device_added_callback(
31 const U2fDeviceAddedCallback& device_added_cb) {
32 device_added_cb_ = device_added_cb;
33 }
34 void set_device_removed_callback(
35 const U2fDeviceRemovedCallback& device_removed_cb) {
36 device_removed_cb_ = device_removed_cb;
37 }
38
39 private:
40 void OnHidEnumerationComplete(
41 U2fEnumerate::U2fEnumerateCallback callback,
42 const std::vector<scoped_refptr<HidDeviceInfo>>& devices);
43 void OnDeviceAdded(scoped_refptr<HidDeviceInfo> device_info) override;
44 void OnDeviceRemoved(scoped_refptr<HidDeviceInfo> device_info) override;
45
46 HidDeviceFilter filter_;
47 U2fDeviceAddedCallback device_added_cb_;
48 U2fDeviceRemovedCallback device_removed_cb_;
49 ScopedObserver<HidService, HidService::Observer> hid_service_observer_;
50 base::WeakPtrFactory<U2fEnumerate> weak_factory_;
51 };
52
53 } // namespace device
54 #endif // DEVICE_U2F_U2F_ENUMERATE_H_
OLDNEW
« no previous file with comments | « device/u2f/u2f_device.h ('k') | device/u2f/u2f_enumerate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698