 Chromium Code Reviews
 Chromium Code Reviews Issue 143883005:
  HID backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base
    
  
    Issue 143883005:
  HID backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 struct udev_device; | |
| 17 | |
| 18 namespace device { | |
| 19 | |
| 20 class HidConnection; | |
| 21 | |
| 22 template<typename T, void func(T*)> | |
| 
Ken Rockot(use gerrit already)
2014/01/21 23:03:39
Can this struct and all the typedefs instead be pr
 
Bei Zhang
2014/01/24 12:48:47
I believe the whole file is pretty private. Since
 | |
| 23 struct GeneralDeleter { | |
| 
Ken Rockot(use gerrit already)
2014/01/21 23:03:39
naming nit: How about just Deleter? It's already g
 
Bei Zhang
2014/01/24 12:48:47
Wonderful!!! Now I can fit everything in 80chs.
 | |
| 24 void operator()(T* enumerate) const { | |
| 25 if (enumerate != NULL) | |
| 26 func(enumerate); | |
| 27 } | |
| 28 }; | |
| 29 | |
| 30 typedef GeneralDeleter<udev_enumerate, udev_enumerate_unref> | |
| 31 UdevEnumerateDeleter; | |
| 32 typedef GeneralDeleter<udev_device, udev_device_unref> UdevDeviceDeleter; | |
| 33 typedef GeneralDeleter<udev, udev_unref> UdevDeleter; | |
| 34 typedef GeneralDeleter<udev_monitor, udev_monitor_unref> UdevMonitorDeleter; | |
| 35 | |
| 36 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr; | |
| 37 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> | |
| 38 ScopedUdevEnumeratePtr; | |
| 39 | |
| 40 class HidServiceLinux : public HidService, | |
| 41 public base::MessagePumpLibevent::Watcher { | |
| 42 public: | |
| 43 HidServiceLinux(); | |
| 44 | |
| 45 virtual scoped_refptr<HidConnection> Connect(std::string device_id) OVERRIDE; | |
| 46 | |
| 47 // Implements base::MessagePumpLibevent::Watcher | |
| 48 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 49 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 virtual ~HidServiceLinux(); | |
| 53 | |
| 54 void Enumerate(); | |
| 55 void PlatformDeviceAdd(udev_device* device); | |
| 56 void PlatformDeviceRemove(udev_device* raw_dev); | |
| 57 | |
| 58 scoped_ptr<udev, UdevDeleter> udev_; | |
| 59 scoped_ptr<udev_monitor, UdevMonitorDeleter> monitor_; | |
| 60 int monitor_fd_; | |
| 61 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); | |
| 64 }; | |
| 65 | |
| 66 } // namespace device | |
| 67 | |
| 68 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ | |
| OLD | NEW |