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 #include "device/hid/hid_connection_linux.h" | 5 #include "device/hid/hid_connection_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/hidraw.h> | 8 #include <linux/hidraw.h> |
9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 base::WeakPtr<HidConnectionLinux> connection, | 36 base::WeakPtr<HidConnectionLinux> connection, |
37 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 37 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
38 : platform_file_(platform_file), | 38 : platform_file_(platform_file), |
39 connection_(connection), | 39 connection_(connection), |
40 task_runner_(task_runner) { | 40 task_runner_(task_runner) { |
41 // Report buffers must always have room for the report ID. | 41 // Report buffers must always have room for the report ID. |
42 report_buffer_size_ = device_info.max_input_report_size + 1; | 42 report_buffer_size_ = device_info.max_input_report_size + 1; |
43 has_report_id_ = device_info.has_report_id; | 43 has_report_id_ = device_info.has_report_id; |
44 } | 44 } |
45 | 45 |
46 virtual ~Helper() { DCHECK(thread_checker_.CalledOnValidThread()); } | 46 ~Helper() override { DCHECK(thread_checker_.CalledOnValidThread()); } |
47 | 47 |
48 // Starts the FileDescriptorWatcher that reads input events from the device. | 48 // Starts the FileDescriptorWatcher that reads input events from the device. |
49 // Must be called on a thread that has a base::MessageLoopForIO. The helper | 49 // Must be called on a thread that has a base::MessageLoopForIO. The helper |
50 // object is owned by the thread where it was started. | 50 // object is owned by the thread where it was started. |
51 void Start() { | 51 void Start() { |
52 base::ThreadRestrictions::AssertIOAllowed(); | 52 base::ThreadRestrictions::AssertIOAllowed(); |
53 thread_checker_.DetachFromThread(); | 53 thread_checker_.DetachFromThread(); |
54 if (!base::MessageLoopForIO::current()->WatchFileDescriptor( | 54 if (!base::MessageLoopForIO::current()->WatchFileDescriptor( |
55 platform_file_, true, base::MessageLoopForIO::WATCH_READ, | 55 platform_file_, true, base::MessageLoopForIO::WATCH_READ, |
56 &file_watcher_, this)) { | 56 &file_watcher_, this)) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 PendingHidReport report = pending_reports_.front(); | 297 PendingHidReport report = pending_reports_.front(); |
298 | 298 |
299 pending_reports_.pop(); | 299 pending_reports_.pop(); |
300 if (CompleteRead(report.buffer, report.size, read.callback)) { | 300 if (CompleteRead(report.buffer, report.size, read.callback)) { |
301 pending_reads_.pop(); | 301 pending_reads_.pop(); |
302 } | 302 } |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 } // namespace device | 306 } // namespace device |
OLD | NEW |