OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 DEVICE_U2F_U2F_HID_DEVICE_H_ | 5 #ifndef DEVICE_U2F_U2F_HID_DEVICE_H_ |
6 #define DEVICE_U2F_U2F_HID_DEVICE_H_ | 6 #define DEVICE_U2F_U2F_HID_DEVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
| 10 #include "base/cancelable_callback.h" |
10 #include "device/hid/hid_service.h" | 11 #include "device/hid/hid_service.h" |
11 #include "u2f_device.h" | 12 #include "u2f_device.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 class IOBuffer; | 15 class IOBuffer; |
15 } // namespace net | 16 } // namespace net |
16 | 17 |
17 namespace device { | 18 namespace device { |
18 | 19 |
19 class U2fMessage; | 20 class U2fMessage; |
20 class HidConnection; | 21 class HidConnection; |
21 class HidDeviceInfo; | 22 class HidDeviceInfo; |
22 | 23 |
23 class U2fHidDevice : public U2fDevice { | 24 class U2fHidDevice : public U2fDevice { |
24 public: | 25 public: |
25 U2fHidDevice(scoped_refptr<HidDeviceInfo>); | 26 U2fHidDevice(scoped_refptr<HidDeviceInfo>); |
26 ~U2fHidDevice(); | 27 ~U2fHidDevice() final; |
27 | 28 |
28 // Send a U2f command to this device | 29 // Send a U2f command to this device |
29 void DeviceTransact(std::unique_ptr<U2fApduCommand> command, | 30 void DeviceTransact(std::unique_ptr<U2fApduCommand> command, |
30 const DeviceCallback& callback) final; | 31 const DeviceCallback& callback) final; |
31 // Send a wink command if supported | 32 // Send a wink command if supported |
32 void TryWink(const WinkCallback& callback) final; | 33 void TryWink(const WinkCallback& callback) final; |
33 // Use a string identifier to compare to other devices | 34 // Use a string identifier to compare to other devices |
34 std::string GetId() final; | 35 std::string GetId() final; |
35 // Command line flag to enable tests on actual U2f HID hardware | 36 // Command line flag to enable tests on actual U2f HID hardware |
36 static bool IsTestEnabled(); | 37 static bool IsTestEnabled(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 scoped_refptr<net::IOBuffer> buf, | 79 scoped_refptr<net::IOBuffer> buf, |
79 size_t size); | 80 size_t size); |
80 void OnReadContinuation(std::unique_ptr<U2fMessage> message, | 81 void OnReadContinuation(std::unique_ptr<U2fMessage> message, |
81 U2fHidMessageCallback, | 82 U2fHidMessageCallback, |
82 bool success, | 83 bool success, |
83 scoped_refptr<net::IOBuffer> buf, | 84 scoped_refptr<net::IOBuffer> buf, |
84 size_t size); | 85 size_t size); |
85 void OnWink(const WinkCallback& callback, | 86 void OnWink(const WinkCallback& callback, |
86 bool success, | 87 bool success, |
87 std::unique_ptr<U2fMessage> response); | 88 std::unique_ptr<U2fMessage> response); |
| 89 void ArmTimeout(const DeviceCallback& callback); |
| 90 void OnTimeout(const DeviceCallback& callback); |
| 91 void OnDeviceTransact(bool success, |
| 92 std::unique_ptr<U2fApduResponse> response); |
88 | 93 |
89 State state_; | 94 State state_; |
| 95 base::CancelableClosure timeout_callback_; |
90 std::list<std::pair<std::unique_ptr<U2fApduCommand>, DeviceCallback>> | 96 std::list<std::pair<std::unique_ptr<U2fApduCommand>, DeviceCallback>> |
91 pending_transactions_; | 97 pending_transactions_; |
92 scoped_refptr<HidDeviceInfo> device_info_; | 98 scoped_refptr<HidDeviceInfo> device_info_; |
93 scoped_refptr<HidConnection> connection_; | 99 scoped_refptr<HidConnection> connection_; |
94 base::WeakPtrFactory<U2fHidDevice> weak_factory_; | 100 base::WeakPtrFactory<U2fHidDevice> weak_factory_; |
95 | 101 |
96 DISALLOW_COPY_AND_ASSIGN(U2fHidDevice); | 102 DISALLOW_COPY_AND_ASSIGN(U2fHidDevice); |
97 }; | 103 }; |
98 | 104 |
99 } // namespace device | 105 } // namespace device |
100 | 106 |
101 #endif // DEVICE_U2F_U2F_HID_DEVICE_H_ | 107 #endif // DEVICE_U2F_U2F_HID_DEVICE_H_ |
OLD | NEW |