| 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_LINUX_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_LINUX_H_ |
| 6 #define DEVICE_HID_HID_SERVICE_LINUX_H_ | 6 #define DEVICE_HID_HID_SERVICE_LINUX_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "device/hid/device_monitor_linux.h" | 11 #include "device/hid/device_monitor_linux.h" |
| 12 #include "device/hid/hid_device_info.h" | 12 #include "device/hid/hid_device_info.h" |
| 13 #include "device/hid/hid_service.h" | 13 #include "device/hid/hid_service.h" |
| 14 | 14 |
| 15 struct udev_device; | 15 struct udev_device; |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 class HidConnection; | 19 class HidConnection; |
| 20 | 20 |
| 21 class HidServiceLinux : public HidService, | 21 class HidServiceLinux : public HidService, |
| 22 public DeviceMonitorLinux::Observer { | 22 public DeviceMonitorLinux::Observer { |
| 23 public: | 23 public: |
| 24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 25 | 25 |
| 26 #if defined(OS_CHROMEOS) | 26 virtual void Connect(const HidDeviceId& device_id, |
| 27 virtual void RequestAccess( | 27 const ConnectCallback& callback) override; |
| 28 const HidDeviceId& device_id, | |
| 29 const base::Callback<void(bool success)>& callback) override; | |
| 30 #endif | |
| 31 | |
| 32 virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id) | |
| 33 override; | |
| 34 | 28 |
| 35 // Implements DeviceMonitorLinux::Observer: | 29 // Implements DeviceMonitorLinux::Observer: |
| 36 virtual void OnDeviceAdded(udev_device* device) override; | 30 virtual void OnDeviceAdded(udev_device* device) override; |
| 37 virtual void OnDeviceRemoved(udev_device* device) override; | 31 virtual void OnDeviceRemoved(udev_device* device) override; |
| 38 | 32 |
| 39 private: | 33 private: |
| 40 virtual ~HidServiceLinux(); | 34 virtual ~HidServiceLinux(); |
| 41 | 35 |
| 42 void OnRequestAccessComplete( | 36 void FinishConnect(const HidDeviceId& device_id, |
| 43 const base::Callback<void(bool success)>& callback, | 37 const std::string device_node, |
| 44 bool success); | 38 const ConnectCallback& callback, |
| 39 bool success); |
| 45 | 40 |
| 46 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 41 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 42 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 48 | 43 |
| 49 base::WeakPtrFactory<HidServiceLinux> weak_factory_; | 44 base::WeakPtrFactory<HidServiceLinux> weak_factory_; |
| 50 | 45 |
| 51 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); | 46 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); |
| 52 }; | 47 }; |
| 53 | 48 |
| 54 } // namespace device | 49 } // namespace device |
| 55 | 50 |
| 56 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ | 51 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ |
| OLD | NEW |