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

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

Issue 256673002: HID: Support top-level collection usages in device info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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.gyp ('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 <queue> 8 #include <queue>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_pump_libevent.h" 12 #include "base/message_loop/message_pump_libevent.h"
13 #include "device/hid/hid_connection.h" 13 #include "device/hid/hid_connection.h"
14 #include "device/hid/hid_device_info.h" 14 #include "device/hid/hid_device_info.h"
15 #include "device/hid/udev_common.h" 15 #include "device/hid/udev_common.h"
16 16
17 namespace device { 17 namespace device {
18 18
19 class HidConnectionLinux : public HidConnection, 19 class HidConnectionLinux : public HidConnection,
20 public base::MessagePumpLibevent::Watcher { 20 public base::MessagePumpLibevent::Watcher {
21 public: 21 public:
22 HidConnectionLinux(HidDeviceInfo device_info, 22 HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node);
23 ScopedUdevDevicePtr udev_raw_device);
24 23
25 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, 24 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
26 const IOCallback& callback) OVERRIDE; 25 const IOCallback& callback) OVERRIDE;
27 virtual void Write(uint8_t report_id, 26 virtual void Write(uint8_t report_id,
28 scoped_refptr<net::IOBufferWithSize> buffer, 27 scoped_refptr<net::IOBufferWithSize> buffer,
29 const IOCallback& callback) OVERRIDE; 28 const IOCallback& callback) OVERRIDE;
30 virtual void GetFeatureReport(uint8_t report_id, 29 virtual void GetFeatureReport(uint8_t report_id,
31 scoped_refptr<net::IOBufferWithSize> buffer, 30 scoped_refptr<net::IOBufferWithSize> buffer,
32 const IOCallback& callback) OVERRIDE; 31 const IOCallback& callback) OVERRIDE;
33 virtual void SendFeatureReport(uint8_t report_id, 32 virtual void SendFeatureReport(uint8_t report_id,
34 scoped_refptr<net::IOBufferWithSize> buffer, 33 scoped_refptr<net::IOBufferWithSize> buffer,
35 const IOCallback& callback) OVERRIDE; 34 const IOCallback& callback) OVERRIDE;
36 35
37 // Implements base::MessagePumpLibevent::Watcher 36 // Implements base::MessagePumpLibevent::Watcher
38 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 37 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
39 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 38 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
40 39
41 private: 40 private:
42 friend class base::RefCountedThreadSafe<HidConnectionLinux>; 41 friend class base::RefCountedThreadSafe<HidConnectionLinux>;
43 virtual ~HidConnectionLinux(); 42 virtual ~HidConnectionLinux();
44 43
45 static bool FindHidrawDevNode(udev_device* parent, std::string* result);
46
47 void ProcessReadQueue(); 44 void ProcessReadQueue();
48 void Disconnect(); 45 void Disconnect();
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 base::ThreadChecker thread_checker_; 53 base::ThreadChecker thread_checker_;
57 54
58 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); 55 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux);
59 }; 56 };
60 57
61 } // namespace device 58 } // namespace device
62 59
63 #endif // DEVICE_HID_HID_CONNECTION_LINUX__ 60 #endif // DEVICE_HID_HID_CONNECTION_LINUX__
OLDNEW
« no previous file with comments | « device/hid/hid.gyp ('k') | device/hid/hid_connection_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698