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

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

Issue 317783010: chrome.hid: enrich model with report IDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Filter reports + refactor HID connections (ongoing) Created 6 years, 6 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
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>
9
10 #include "base/files/file.h" 8 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_pump_libevent.h" 9 #include "base/message_loop/message_pump_libevent.h"
13 #include "device/hid/hid_connection.h" 10 #include "device/hid/hid_connection.h"
14 #include "device/hid/hid_device_info.h"
15 11
16 namespace device { 12 namespace device {
17 13
18 class HidConnectionLinux : public HidConnection, 14 class HidConnectionLinux : public HidConnection2,
19 public base::MessagePumpLibevent::Watcher { 15 public base::MessagePumpLibevent::Watcher {
20 public: 16 public:
21 HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node); 17 explicit HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node);
Ken Rockot(use gerrit already) 2014/06/19 19:29:57 Only need explicit for single-argument constructor
jracle (use Gerrit) 2014/06/19 21:39:37 oh indeed! Thanks On 2014/06/19 19:29:57, Ken Roc
22 18
23 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, 19 // HidConnection implementation.
24 const IOCallback& callback) OVERRIDE; 20 virtual void PlatformWrite(uint8_t report_id,
25 virtual void Write(uint8_t report_id, 21 scoped_refptr<net::IOBufferWithSize> buffer,
26 scoped_refptr<net::IOBufferWithSize> buffer, 22 const IOCallback& callback) OVERRIDE;
27 const IOCallback& callback) OVERRIDE; 23 virtual void PlatformGetFeatureReport(
28 virtual void GetFeatureReport(uint8_t report_id, 24 uint8_t report_id,
29 scoped_refptr<net::IOBufferWithSize> buffer, 25 scoped_refptr<net::IOBufferWithSize> buffer,
30 const IOCallback& callback) OVERRIDE; 26 const IOCallback& callback) OVERRIDE;
31 virtual void SendFeatureReport(uint8_t report_id, 27 virtual void PlatformSendFeatureReport(
32 scoped_refptr<net::IOBufferWithSize> buffer, 28 uint8_t report_id,
33 const IOCallback& callback) OVERRIDE; 29 scoped_refptr<net::IOBufferWithSize> buffer,
30 const IOCallback& callback) OVERRIDE;
34 31
35 // Implements base::MessagePumpLibevent::Watcher 32 // base::MessagePumpLibevent::Watcher implementation.
36 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 33 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
37 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 34 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
38 35
39 private: 36 private:
40 friend class base::RefCountedThreadSafe<HidConnectionLinux>; 37 friend class base::RefCountedThreadSafe<HidConnectionLinux>;
41 virtual ~HidConnectionLinux(); 38 virtual ~HidConnectionLinux();
42 39
43 void ProcessReadQueue();
44 void Disconnect(); 40 void Disconnect();
45 41
46 base::File device_file_; 42 base::File device_file_;
47 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; 43 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_;
48 44
49 std::queue<PendingHidReport> pending_reports_;
50 std::queue<PendingHidRead> pending_reads_;
51
52 base::ThreadChecker thread_checker_;
53
54 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); 45 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux);
55 }; 46 };
56 47
57 } // namespace device 48 } // namespace device
58 49
59 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_ 50 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698