| OLD | NEW |
| 1 // Copyright (c) 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 <libudev.h> | 8 #include <libudev.h> |
| 9 | 9 |
| 10 #include <map> |
| 11 #include <string> |
| 12 |
| 10 #include "base/macros.h" | 13 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_pump_libevent.h" | 15 #include "base/message_loop/message_pump_libevent.h" |
| 13 #include "device/hid/hid_device_info.h" | 16 #include "device/hid/hid_device_info.h" |
| 14 #include "device/hid/hid_service.h" | 17 #include "device/hid/hid_service.h" |
| 15 | 18 |
| 16 namespace device { | 19 namespace device { |
| 17 | 20 |
| 18 class HidConnection; | 21 class HidConnection; |
| 19 | 22 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 DiscardReturnType<udev_monitor, udev_monitor_unref> > UdevMonitorDeleter; | 46 DiscardReturnType<udev_monitor, udev_monitor_unref> > UdevMonitorDeleter; |
| 44 | 47 |
| 45 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr; | 48 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr; |
| 46 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr; | 49 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr; |
| 47 | 50 |
| 48 class HidServiceLinux : public HidService, | 51 class HidServiceLinux : public HidService, |
| 49 public base::MessagePumpLibevent::Watcher { | 52 public base::MessagePumpLibevent::Watcher { |
| 50 public: | 53 public: |
| 51 HidServiceLinux(); | 54 HidServiceLinux(); |
| 52 | 55 |
| 53 virtual scoped_refptr<HidConnection> Connect(std::string device_id) OVERRIDE; | 56 virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id) |
| 57 OVERRIDE; |
| 54 | 58 |
| 55 // Implements base::MessagePumpLibevent::Watcher | 59 // Implements base::MessagePumpLibevent::Watcher |
| 56 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 60 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 57 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 61 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 virtual ~HidServiceLinux(); | 64 virtual ~HidServiceLinux(); |
| 61 | 65 |
| 62 void Enumerate(); | 66 void Enumerate(); |
| 63 void PlatformDeviceAdd(udev_device* device); | 67 void PlatformAddDevice(udev_device* device); |
| 64 void PlatformDeviceRemove(udev_device* raw_dev); | 68 void PlatformRemoveDevice(udev_device* raw_dev); |
| 65 | 69 |
| 66 scoped_ptr<udev, UdevDeleter> udev_; | 70 scoped_ptr<udev, UdevDeleter> udev_; |
| 67 scoped_ptr<udev_monitor, UdevMonitorDeleter> monitor_; | 71 scoped_ptr<udev_monitor, UdevMonitorDeleter> monitor_; |
| 68 int monitor_fd_; | 72 int monitor_fd_; |
| 69 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; | 73 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); | 75 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace device | 78 } // namespace device |
| 75 | 79 |
| 76 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ | 80 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ |
| OLD | NEW |