| 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_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(scoped_refptr<net::IOBuffer> buffer, | |
| 25 size_t size, | |
| 26 const IOCallback& callback) OVERRIDE; | |
| 27 virtual void Write(scoped_refptr<net::IOBuffer> buffer, | |
| 28 size_t size, | |
| 29 const IOCallback& callback) OVERRIDE; | |
| 30 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, | |
| 31 size_t size, | |
| 32 const IOCallback& callback) OVERRIDE; | |
| 33 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, | |
| 34 size_t size, | |
| 35 const IOCallback& callback) OVERRIDE; | |
| 36 | |
| 37 bool initialized() const { return initialized_; } | |
| 38 | |
| 39 // Implements base::MessagePumpLibevent::Watcher | |
| 40 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 41 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 42 | |
| 43 private: | |
| 44 friend class base::RefCountedThreadSafe<HidConnectionLinux>; | |
| 45 virtual ~HidConnectionLinux(); | |
| 46 | |
| 47 static bool FindHidrawDevNode(udev_device* parent, std::string* result); | |
| 48 | |
| 49 void ProcessReadQueue(); | |
| 50 void Disconnect(); | |
| 51 | |
| 52 base::PlatformFile device_file_; | |
| 53 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; | |
| 54 | |
| 55 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> PendingReport; | |
| 56 typedef Tuple3<scoped_refptr<net::IOBuffer>, size_t, IOCallback> | |
| 57 PendingRequest; | |
| 58 | |
| 59 std::queue<PendingReport> input_reports_; | |
| 60 std::queue<PendingRequest> read_queue_; | |
| 61 | |
| 62 bool initialized_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); | |
| 65 }; | |
| 66 | |
| 67 } // namespace device | |
| 68 | |
| 69 #endif // DEVICE_HID_HID_CONNECTION_LINUX__ | |
| OLD | NEW |