OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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_CONNECTION_LINUX_H_ | 5 #ifndef DEVICE_HID_HID_CONNECTION_LINUX_H_ |
6 #define DEVICE_HID_HID_CONNECTION_LINUX_H_ | 6 #define DEVICE_HID_HID_CONNECTION_LINUX_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/message_loop/message_pump_libevent.h" | 11 #include "base/message_loop/message_pump_libevent.h" |
12 #include "device/hid/hid_connection.h" | 12 #include "device/hid/hid_connection.h" |
13 | 13 |
14 namespace device { | 14 namespace device { |
15 | 15 |
16 class HidConnectionLinux : public HidConnection, | 16 class HidConnectionLinux : public HidConnection, |
17 public base::MessagePumpLibevent::Watcher { | 17 public base::MessagePumpLibevent::Watcher { |
18 public: | 18 public: |
19 HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node); | 19 HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node); |
20 | 20 |
21 // HidConnection implementation. | 21 // HidConnection implementation. |
22 virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer, | 22 virtual void PlatformRead(const ReadCallback& callback) OVERRIDE; |
23 const IOCallback& callback) OVERRIDE; | 23 virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, |
24 virtual void PlatformWrite(uint8_t report_id, | 24 size_t size, |
25 scoped_refptr<net::IOBufferWithSize> buffer, | 25 const WriteCallback& callback) OVERRIDE; |
26 const IOCallback& callback) OVERRIDE; | 26 virtual void PlatformGetFeatureReport(uint8_t report_id, |
27 virtual void PlatformGetFeatureReport( | 27 const ReadCallback& callback) OVERRIDE; |
28 uint8_t report_id, | |
29 scoped_refptr<net::IOBufferWithSize> buffer, | |
30 const IOCallback& callback) OVERRIDE; | |
31 virtual void PlatformSendFeatureReport( | 28 virtual void PlatformSendFeatureReport( |
32 uint8_t report_id, | 29 scoped_refptr<net::IOBuffer> buffer, |
33 scoped_refptr<net::IOBufferWithSize> buffer, | 30 size_t size, |
34 const IOCallback& callback) OVERRIDE; | 31 const WriteCallback& callback) OVERRIDE; |
35 | 32 |
36 // base::MessagePumpLibevent::Watcher implementation. | 33 // base::MessagePumpLibevent::Watcher implementation. |
37 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 34 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
38 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 35 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
39 | 36 |
40 private: | 37 private: |
41 friend class base::RefCountedThreadSafe<HidConnectionLinux>; | 38 friend class base::RefCountedThreadSafe<HidConnectionLinux>; |
42 virtual ~HidConnectionLinux(); | 39 virtual ~HidConnectionLinux(); |
43 | 40 |
44 void Disconnect(); | 41 void Disconnect(); |
45 | 42 |
46 void Flush(); | 43 void Flush(); |
47 void ProcessInputReport(scoped_refptr<net::IOBufferWithSize> buffer); | 44 void ProcessInputReport(scoped_refptr<net::IOBuffer> buffer, size_t size); |
48 void ProcessReadQueue(); | 45 void ProcessReadQueue(); |
49 | 46 |
50 base::File device_file_; | 47 base::File device_file_; |
51 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; | 48 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; |
52 | 49 |
53 std::queue<PendingHidReport> pending_reports_; | 50 std::queue<PendingHidReport> pending_reports_; |
54 std::queue<PendingHidRead> pending_reads_; | 51 std::queue<PendingHidRead> pending_reads_; |
55 | 52 |
56 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); | 53 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); |
57 }; | 54 }; |
58 | 55 |
59 } // namespace device | 56 } // namespace device |
60 | 57 |
61 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_ | 58 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_ |
OLD | NEW |