Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: device/hid/hid_connection_linux.h

Issue 161823002: Clean up HID backend and API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/hid/hid_connection.cc ('k') | device/hid/hid_connection_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/tuple.h"
11 #include "device/hid/hid_connection.h" 10 #include "device/hid/hid_connection.h"
12 #include "device/hid/hid_device_info.h" 11 #include "device/hid/hid_device_info.h"
13 #include "device/hid/hid_service_linux.h" 12 #include "device/hid/hid_service_linux.h"
14 #include "net/base/io_buffer.h"
15 13
16 namespace device { 14 namespace device {
17 15
18 class HidConnectionLinux : public HidConnection, 16 class HidConnectionLinux : public HidConnection,
19 public base::MessagePumpLibevent::Watcher { 17 public base::MessagePumpLibevent::Watcher {
20 public: 18 public:
21 HidConnectionLinux(HidDeviceInfo device_info, 19 HidConnectionLinux(HidDeviceInfo device_info,
22 ScopedUdevDevicePtr udev_raw_device); 20 ScopedUdevDevicePtr udev_raw_device);
23 21
24 virtual void Read(scoped_refptr<net::IOBuffer> buffer, 22 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
25 size_t size,
26 const IOCallback& callback) OVERRIDE; 23 const IOCallback& callback) OVERRIDE;
27 virtual void Write(scoped_refptr<net::IOBuffer> buffer, 24 virtual void Write(uint8_t report_id,
28 size_t size, 25 scoped_refptr<net::IOBufferWithSize> buffer,
29 const IOCallback& callback) OVERRIDE; 26 const IOCallback& callback) OVERRIDE;
30 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, 27 virtual void GetFeatureReport(uint8_t report_id,
31 size_t size, 28 scoped_refptr<net::IOBufferWithSize> buffer,
32 const IOCallback& callback) OVERRIDE; 29 const IOCallback& callback) OVERRIDE;
33 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 30 virtual void SendFeatureReport(uint8_t report_id,
34 size_t size, 31 scoped_refptr<net::IOBufferWithSize> buffer,
35 const IOCallback& callback) OVERRIDE; 32 const IOCallback& callback) OVERRIDE;
36 33
37 bool initialized() const { return initialized_; }
38
39 // Implements base::MessagePumpLibevent::Watcher 34 // Implements base::MessagePumpLibevent::Watcher
40 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
41 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
42 37
43 private: 38 private:
44 friend class base::RefCountedThreadSafe<HidConnectionLinux>; 39 friend class base::RefCountedThreadSafe<HidConnectionLinux>;
45 virtual ~HidConnectionLinux(); 40 virtual ~HidConnectionLinux();
46 41
47 static bool FindHidrawDevNode(udev_device* parent, std::string* result); 42 static bool FindHidrawDevNode(udev_device* parent, std::string* result);
48 43
49 void ProcessReadQueue(); 44 void ProcessReadQueue();
50 void Disconnect(); 45 void Disconnect();
51 46
52 base::File device_file_; 47 base::File device_file_;
53 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; 48 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_;
54 49
55 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> PendingReport; 50 std::queue<PendingHidReport> pending_reports_;
56 typedef Tuple3<scoped_refptr<net::IOBuffer>, size_t, IOCallback> 51 std::queue<PendingHidRead> pending_reads_;
57 PendingRequest;
58 52
59 std::queue<PendingReport> input_reports_; 53 base::ThreadChecker thread_checker_;
60 std::queue<PendingRequest> read_queue_;
61
62 bool initialized_;
63 54
64 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); 55 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux);
65 }; 56 };
66 57
67 } // namespace device 58 } // namespace device
68 59
69 #endif // DEVICE_HID_HID_CONNECTION_LINUX__ 60 #endif // DEVICE_HID_HID_CONNECTION_LINUX__
OLDNEW
« no previous file with comments | « device/hid/hid_connection.cc ('k') | device/hid/hid_connection_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698