| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef DEVICE_HID_HID_SERVICE_LINUX_H_ |  | 
| 6 #define DEVICE_HID_HID_SERVICE_LINUX_H_ |  | 
| 7 |  | 
| 8 #include <libudev.h> |  | 
| 9 |  | 
| 10 #include "base/macros.h" |  | 
| 11 #include "base/memory/scoped_ptr.h" |  | 
| 12 #include "base/message_loop/message_pump_libevent.h" |  | 
| 13 #include "device/hid/hid_device_info.h" |  | 
| 14 #include "device/hid/hid_service.h" |  | 
| 15 |  | 
| 16 namespace device { |  | 
| 17 |  | 
| 18 class HidConnection; |  | 
| 19 |  | 
| 20 template<typename T, void func(T*)> |  | 
| 21 struct Deleter { |  | 
| 22   void operator()(T* enumerate) const { |  | 
| 23     if (enumerate != NULL) |  | 
| 24       func(enumerate); |  | 
| 25   } |  | 
| 26 }; |  | 
| 27 |  | 
| 28 typedef Deleter<udev_enumerate, udev_enumerate_unref> UdevEnumerateDeleter; |  | 
| 29 typedef Deleter<udev_device, udev_device_unref> UdevDeviceDeleter; |  | 
| 30 typedef Deleter<udev, udev_unref> UdevDeleter; |  | 
| 31 typedef Deleter<udev_monitor, udev_monitor_unref> UdevMonitorDeleter; |  | 
| 32 |  | 
| 33 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr; |  | 
| 34 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr; |  | 
| 35 |  | 
| 36 class HidServiceLinux : public HidService, |  | 
| 37                         public base::MessagePumpLibevent::Watcher { |  | 
| 38  public: |  | 
| 39   HidServiceLinux(); |  | 
| 40 |  | 
| 41   virtual scoped_refptr<HidConnection> Connect(std::string device_id) OVERRIDE; |  | 
| 42 |  | 
| 43   // Implements base::MessagePumpLibevent::Watcher |  | 
| 44   virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |  | 
| 45   virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |  | 
| 46 |  | 
| 47  private: |  | 
| 48   virtual ~HidServiceLinux(); |  | 
| 49 |  | 
| 50   void Enumerate(); |  | 
| 51   void PlatformDeviceAdd(udev_device* device); |  | 
| 52   void PlatformDeviceRemove(udev_device* raw_dev); |  | 
| 53 |  | 
| 54   scoped_ptr<udev, UdevDeleter> udev_; |  | 
| 55   scoped_ptr<udev_monitor, UdevMonitorDeleter> monitor_; |  | 
| 56   int monitor_fd_; |  | 
| 57   base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; |  | 
| 58 |  | 
| 59   DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); |  | 
| 60 }; |  | 
| 61 |  | 
| 62 }  // namespace device |  | 
| 63 |  | 
| 64 #endif  // DEVICE_HID_HID_SERVICE_LINUX_H_ |  | 
| OLD | NEW | 
|---|