| 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_CONNECTION_LINUX_H_ |
| 6 #define DEVICE_HID_HID_CONNECTION_LINUX_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/platform_file.h" |
| 10 #include "base/tuple.h" |
| 11 #include "device/hid/hid_connection.h" |
| 12 #include "device/hid/hid_device_info.h" |
| 13 #include "device/hid/hid_service_linux.h" |
| 14 #include "net/base/io_buffer.h" |
| 15 |
| 16 namespace device { |
| 17 |
| 18 class HidConnectionLinux : public HidConnection, |
| 19 public base::MessagePumpLibevent::Watcher { |
| 20 public: |
| 21 HidConnectionLinux(HidDeviceInfo device_info, |
| 22 ScopedUdevDevicePtr udev_raw_device); |
| 23 |
| 24 virtual void Read(const HidIOCallback& callback) OVERRIDE; |
| 25 virtual void Write(scoped_refptr<net::IOBuffer> buffer, |
| 26 size_t size, |
| 27 const HidIOCallback& callback) OVERRIDE; |
| 28 virtual void GetFeatureReport(const HidIOCallback& callback) OVERRIDE; |
| 29 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, |
| 30 size_t size, |
| 31 const HidIOCallback& callback) OVERRIDE; |
| 32 |
| 33 bool initialized() const { return initialized_; } |
| 34 |
| 35 // Implements base::MessagePumpLibevent::Watcher |
| 36 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 37 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 38 |
| 39 private: |
| 40 friend class base::RefCountedThreadSafe<HidConnectionLinux>; |
| 41 virtual ~HidConnectionLinux(); |
| 42 |
| 43 static bool FindHidrawDevNode(udev_device* parent, std::string* result); |
| 44 |
| 45 void ProcessReadQueue(); |
| 46 void ProcessWriteQueue(); |
| 47 void Disconnect(); |
| 48 |
| 49 base::PlatformFile device_file_; |
| 50 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; |
| 51 |
| 52 std::queue<std::pair<scoped_refptr<net::IOBuffer>, size_t> > input_reports_; |
| 53 std::queue<HidIOCallback> read_queue_; |
| 54 std::queue<Tuple3<scoped_refptr<net::IOBuffer>, size_t, HidIOCallback> > |
| 55 write_queue_; |
| 56 |
| 57 bool initialized_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); |
| 60 }; |
| 61 |
| 62 } // namespace device |
| 63 |
| 64 #endif // DEVICE_HID_HID_CONNECTION_LINUX__ |
| OLD | NEW |