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

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

Issue 225513005: chrome.hid : enrich device info with Top-Level collections usages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatted code (git cl format) Created 6 years, 8 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 "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 "device/hid/hid_connection.h" 10 #include "device/hid/hid_connection.h"
11 #include "device/hid/hid_device_info.h" 11 #include "device/hid/hid_device_info.h"
12 #include "device/hid/hid_service_linux.h" 12 #include "device/hid/hid_service_linux.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, 19 HidConnectionLinux(HidDeviceInfo device_info, std::string dev_node);
20 ScopedUdevDevicePtr udev_raw_device);
21 20
22 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, 21 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
23 const IOCallback& callback) OVERRIDE; 22 const IOCallback& callback) OVERRIDE;
24 virtual void Write(uint8_t report_id, 23 virtual void Write(uint8_t report_id,
25 scoped_refptr<net::IOBufferWithSize> buffer, 24 scoped_refptr<net::IOBufferWithSize> buffer,
26 const IOCallback& callback) OVERRIDE; 25 const IOCallback& callback) OVERRIDE;
27 virtual void GetFeatureReport(uint8_t report_id, 26 virtual void GetFeatureReport(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 SendFeatureReport(uint8_t report_id, 29 virtual void SendFeatureReport(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 32
34 // Implements base::MessagePumpLibevent::Watcher 33 // Implements base::MessagePumpLibevent::Watcher
35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 34 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 35 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
37 36
38 private: 37 private:
39 friend class base::RefCountedThreadSafe<HidConnectionLinux>; 38 friend class base::RefCountedThreadSafe<HidConnectionLinux>;
40 virtual ~HidConnectionLinux(); 39 virtual ~HidConnectionLinux();
41 40
42 static bool FindHidrawDevNode(udev_device* parent, std::string* result);
43
44 void ProcessReadQueue(); 41 void ProcessReadQueue();
45 void Disconnect(); 42 void Disconnect();
46 43
47 base::File device_file_; 44 base::File device_file_;
48 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_; 45 base::MessagePumpLibevent::FileDescriptorWatcher device_file_watcher_;
49 46
50 std::queue<PendingHidReport> pending_reports_; 47 std::queue<PendingHidReport> pending_reports_;
51 std::queue<PendingHidRead> pending_reads_; 48 std::queue<PendingHidRead> pending_reads_;
52 49
53 base::ThreadChecker thread_checker_; 50 base::ThreadChecker thread_checker_;
54 51
55 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); 52 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux);
56 }; 53 };
57 54
58 } // namespace device 55 } // namespace device
59 56
60 #endif // DEVICE_HID_HID_CONNECTION_LINUX__ 57 #endif // DEVICE_HID_HID_CONNECTION_LINUX__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698