OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HID_HID_SERVICE_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_H_ |
6 #define DEVICE_HID_HID_SERVICE_H_ | 6 #define DEVICE_HID_HID_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "device/hid/hid_device_info.h" | 15 #include "device/hid/hid_device_info.h" |
16 | 16 |
17 namespace device { | 17 namespace device { |
18 | 18 |
19 class HidConnection; | 19 class HidConnection; |
20 | 20 |
21 class HidService { | 21 class HidService { |
22 public: | 22 public: |
23 typedef base::Callback<void(scoped_refptr<HidConnection> connection)> | 23 typedef base::Callback<void(scoped_refptr<HidConnection> connection)> |
24 ConnectCallback; | 24 ConnectCallback; |
25 | 25 |
26 static HidService* GetInstance( | 26 static HidService* GetInstance( |
27 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | 27 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
29 | 29 |
| 30 static void SetInstanceForTest(HidService* instance); |
| 31 |
30 // Enumerates and returns a list of device identifiers. | 32 // Enumerates and returns a list of device identifiers. |
31 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); | 33 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); |
32 | 34 |
33 // Fills in a DeviceInfo struct with info for the given device_id. | 35 // Fills in a DeviceInfo struct with info for the given device_id. |
34 // Returns |true| if successful or |false| if |device_id| is invalid. | 36 // Returns |true| if successful or |false| if |device_id| is invalid. |
35 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; | 37 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; |
36 | 38 |
37 // Opens a connection to a device. The callback will be run with null on | 39 // Opens a connection to a device. The callback will be run with null on |
38 // failure. | 40 // failure. |
39 virtual void Connect(const HidDeviceId& device_id, | 41 virtual void Connect(const HidDeviceId& device_id, |
(...skipping 18 matching lines...) Expand all Loading... |
58 class Destroyer; | 60 class Destroyer; |
59 | 61 |
60 DeviceMap devices_; | 62 DeviceMap devices_; |
61 | 63 |
62 DISALLOW_COPY_AND_ASSIGN(HidService); | 64 DISALLOW_COPY_AND_ASSIGN(HidService); |
63 }; | 65 }; |
64 | 66 |
65 } // namespace device | 67 } // namespace device |
66 | 68 |
67 #endif // DEVICE_HID_HID_SERVICE_H_ | 69 #endif // DEVICE_HID_HID_SERVICE_H_ |
OLD | NEW |