[email protected] | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 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_HID_HID_SERVICE_LINUX_H_ | ||||
6 | #define DEVICE_HID_HID_SERVICE_LINUX_H_ | ||||
7 | |||||
[email protected] | bca53b0 | 2014-04-10 15:11:14 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 9 | #include "base/macros.h" |
[email protected] | 03b640fd | 2014-07-26 18:25:38 | [diff] [blame] | 10 | #include "base/memory/weak_ptr.h" |
[email protected] | bca53b0 | 2014-04-10 15:11:14 | [diff] [blame] | 11 | #include "device/hid/device_monitor_linux.h" |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 12 | #include "device/hid/hid_device_info.h" |
13 | #include "device/hid/hid_service.h" | ||||
14 | |||||
[email protected] | bca53b0 | 2014-04-10 15:11:14 | [diff] [blame] | 15 | struct udev_device; |
16 | |||||
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 17 | namespace device { |
18 | |||||
19 | class HidConnection; | ||||
20 | |||||
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 21 | class HidServiceLinux : public HidService, |
[email protected] | bca53b0 | 2014-04-10 15:11:14 | [diff] [blame] | 22 | public DeviceMonitorLinux::Observer { |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 23 | public: |
rockot | 1a51b92 | 2014-09-05 08:02:44 | [diff] [blame] | 24 | HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 25 | |
dcheng | 07c34a1 | 2014-10-29 18:55:10 | [diff] [blame] | 26 | void Connect(const HidDeviceId& device_id, |
27 | const ConnectCallback& callback) override; | ||||
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 28 | |
[email protected] | eedae13 | 2014-04-12 22:02:37 | [diff] [blame] | 29 | // Implements DeviceMonitorLinux::Observer: |
dcheng | 07c34a1 | 2014-10-29 18:55:10 | [diff] [blame] | 30 | void OnDeviceAdded(udev_device* device) override; |
31 | void OnDeviceRemoved(udev_device* device) override; | ||||
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 32 | |
33 | private: | ||||
dcheng | 07c34a1 | 2014-10-29 18:55:10 | [diff] [blame] | 34 | ~HidServiceLinux() override; |
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 35 | |
reillyg | 7f4f508 | 2014-10-16 19:19:14 | [diff] [blame] | 36 | void FinishConnect(const HidDeviceId& device_id, |
37 | const std::string device_node, | ||||
38 | const ConnectCallback& callback, | ||||
39 | bool success); | ||||
[email protected] | 03b640fd | 2014-07-26 18:25:38 | [diff] [blame] | 40 | |
reillyg | 7832a4e | 2014-10-11 01:52:47 | [diff] [blame] | 41 | scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
rockot | 1a51b92 | 2014-09-05 08:02:44 | [diff] [blame] | 42 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
[email protected] | 03b640fd | 2014-07-26 18:25:38 | [diff] [blame] | 43 | |
44 | base::WeakPtrFactory<HidServiceLinux> weak_factory_; | ||||
45 | |||||
[email protected] | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 46 | DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); |
47 | }; | ||||
48 | |||||
49 | } // namespace device | ||||
50 | |||||
51 | #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ |