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 | |
11 #include <string> | 10 #include <string> |
| 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/message_loop/message_pump_libevent.h" | 17 #include "base/message_loop/message_pump_libevent.h" |
18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
21 #include "components/device_event_log/device_event_log.h" | 21 #include "components/device_event_log/device_event_log.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 }; | 129 }; |
130 | 130 |
131 HidConnectionLinux::HidConnectionLinux( | 131 HidConnectionLinux::HidConnectionLinux( |
132 scoped_refptr<HidDeviceInfo> device_info, | 132 scoped_refptr<HidDeviceInfo> device_info, |
133 base::File device_file, | 133 base::File device_file, |
134 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 134 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) |
135 : HidConnection(device_info), | 135 : HidConnection(device_info), |
136 file_task_runner_(file_task_runner), | 136 file_task_runner_(file_task_runner), |
137 weak_factory_(this) { | 137 weak_factory_(this) { |
138 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 138 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
139 device_file_ = device_file.Pass(); | 139 device_file_ = std::move(device_file); |
140 | 140 |
141 // The helper is passed a weak pointer to this connection so that it can be | 141 // The helper is passed a weak pointer to this connection so that it can be |
142 // cleaned up after the connection is closed. | 142 // cleaned up after the connection is closed. |
143 scoped_ptr<FileThreadHelper> helper( | 143 scoped_ptr<FileThreadHelper> helper( |
144 new FileThreadHelper(device_file_.GetPlatformFile(), device_info, | 144 new FileThreadHelper(device_file_.GetPlatformFile(), device_info, |
145 weak_factory_.GetWeakPtr(), task_runner_)); | 145 weak_factory_.GetWeakPtr(), task_runner_)); |
146 helper_ = helper.get(); | 146 helper_ = helper.get(); |
147 file_task_runner_->PostTask( | 147 file_task_runner_->PostTask( |
148 FROM_HERE, base::Bind(&FileThreadHelper::Start, base::Passed(&helper))); | 148 FROM_HERE, base::Bind(&FileThreadHelper::Start, base::Passed(&helper))); |
149 } | 149 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 PendingHidReport report = pending_reports_.front(); | 317 PendingHidReport report = pending_reports_.front(); |
318 | 318 |
319 pending_reports_.pop(); | 319 pending_reports_.pop(); |
320 if (CompleteRead(report.buffer, report.size, read.callback)) { | 320 if (CompleteRead(report.buffer, report.size, read.callback)) { |
321 pending_reads_.pop(); | 321 pending_reads_.pop(); |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 } // namespace device | 326 } // namespace device |
OLD | NEW |