Lines 1-5
Link Here
|
1 |
--- services/device/hid/hid_connection_freebsd.cc.orig 2019-05-04 09:19:19 UTC |
1 |
--- services/device/hid/hid_connection_freebsd.cc.orig 2020-07-18 19:40:14.410523000 -0700 |
2 |
+++ services/device/hid/hid_connection_freebsd.cc |
2 |
+++ services/device/hid/hid_connection_freebsd.cc 2020-07-21 19:49:59.569331000 -0700 |
3 |
@@ -0,0 +1,240 @@ |
3 |
@@ -0,0 +1,240 @@ |
4 |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
4 |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
5 |
+// Use of this source code is governed by a BSD-style license that can be |
5 |
+// Use of this source code is governed by a BSD-style license that can be |
Lines 26-34
Link Here
|
26 |
+ |
26 |
+ |
27 |
+namespace device { |
27 |
+namespace device { |
28 |
+ |
28 |
+ |
29 |
+class HidConnectionFreeBSD::BlockingTaskHelper { |
29 |
+class HidConnectionFreeBSD::BlockingTaskRunnerHelper { |
30 |
+ public: |
30 |
+ public: |
31 |
+ BlockingTaskHelper(base::ScopedFD fd, |
31 |
+ BlockingTaskRunnerHelper(base::ScopedFD fd, |
32 |
+ scoped_refptr<HidDeviceInfo> device_info, |
32 |
+ scoped_refptr<HidDeviceInfo> device_info, |
33 |
+ base::WeakPtr<HidConnectionFreeBSD> connection) |
33 |
+ base::WeakPtr<HidConnectionFreeBSD> connection) |
34 |
+ : fd_(std::move(fd)), |
34 |
+ : fd_(std::move(fd)), |
Lines 40-46
Link Here
|
40 |
+ has_report_id_ = device_info->has_report_id(); |
40 |
+ has_report_id_ = device_info->has_report_id(); |
41 |
+ } |
41 |
+ } |
42 |
+ |
42 |
+ |
43 |
+ ~BlockingTaskHelper() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } |
43 |
+ ~BlockingTaskRunnerHelper() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } |
44 |
+ |
44 |
+ |
45 |
+ // Starts the FileDescriptorWatcher that reads input events from the device. |
45 |
+ // Starts the FileDescriptorWatcher that reads input events from the device. |
46 |
+ // Must be called on a thread that has a base::MessageLoopForIO. |
46 |
+ // Must be called on a thread that has a base::MessageLoopForIO. |
Lines 49-55
Link Here
|
49 |
+ base::internal::AssertBlockingAllowed(); |
49 |
+ base::internal::AssertBlockingAllowed(); |
50 |
+ |
50 |
+ |
51 |
+ file_watcher_ = base::FileDescriptorWatcher::WatchReadable( |
51 |
+ file_watcher_ = base::FileDescriptorWatcher::WatchReadable( |
52 |
+ fd_.get(), base::Bind(&BlockingTaskHelper::OnFileCanReadWithoutBlocking, |
52 |
+ fd_.get(), base::Bind(&BlockingTaskRunnerHelper::OnFileCanReadWithoutBlocking, |
53 |
+ base::Unretained(this))); |
53 |
+ base::Unretained(this))); |
54 |
+ } |
54 |
+ } |
55 |
+ |
55 |
+ |
Lines 176-182
Link Here
|
176 |
+ const scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
176 |
+ const scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
177 |
+ std::unique_ptr<base::FileDescriptorWatcher::Controller> file_watcher_; |
177 |
+ std::unique_ptr<base::FileDescriptorWatcher::Controller> file_watcher_; |
178 |
+ |
178 |
+ |
179 |
+ DISALLOW_COPY_AND_ASSIGN(BlockingTaskHelper); |
179 |
+ DISALLOW_COPY_AND_ASSIGN(BlockingTaskRunnerHelper); |
180 |
+}; |
180 |
+}; |
181 |
+ |
181 |
+ |
182 |
+HidConnectionFreeBSD::HidConnectionFreeBSD( |
182 |
+HidConnectionFreeBSD::HidConnectionFreeBSD( |
Lines 184-195
Link Here
|
184 |
+ base::ScopedFD fd, |
184 |
+ base::ScopedFD fd, |
185 |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) |
185 |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) |
186 |
+ : HidConnection(device_info), |
186 |
+ : HidConnection(device_info), |
187 |
+ blocking_task_runner_(std::move(blocking_task_runner)), |
187 |
+ helper_(nullptr, base::OnTaskRunnerDeleter(blocking_task_runner)), |
188 |
+ weak_factory_(this) { |
188 |
+ blocking_task_runner_(std::move(blocking_task_runner)) { |
189 |
+ helper_ = std::make_unique<BlockingTaskHelper>(std::move(fd), device_info, |
189 |
+ helper_.reset(new BlockingTaskRunnerHelper(std::move(fd), device_info, |
190 |
+ weak_factory_.GetWeakPtr()); |
190 |
+ weak_factory_.GetWeakPtr())); |
191 |
+ blocking_task_runner_->PostTask( |
191 |
+ blocking_task_runner_->PostTask( |
192 |
+ FROM_HERE, base::BindOnce(&BlockingTaskHelper::Start, |
192 |
+ FROM_HERE, base::BindOnce(&BlockingTaskRunnerHelper::Start, |
193 |
+ base::Unretained(helper_.get()))); |
193 |
+ base::Unretained(helper_.get()))); |
194 |
+} |
194 |
+} |
195 |
+ |
195 |
+ |
Lines 208-214
Link Here
|
208 |
+ |
208 |
+ |
209 |
+ blocking_task_runner_->PostTask( |
209 |
+ blocking_task_runner_->PostTask( |
210 |
+ FROM_HERE, |
210 |
+ FROM_HERE, |
211 |
+ base::BindOnce(&BlockingTaskHelper::Write, base::Unretained(helper_.get()), |
211 |
+ base::BindOnce(&BlockingTaskRunnerHelper::Write, base::Unretained(helper_.get()), |
212 |
+ buffer, std::move(callback))); |
212 |
+ buffer, std::move(callback))); |
213 |
+} |
213 |
+} |
214 |
+ |
214 |
+ |
Lines 224-230
Link Here
|
224 |
+ |
224 |
+ |
225 |
+ blocking_task_runner_->PostTask( |
225 |
+ blocking_task_runner_->PostTask( |
226 |
+ FROM_HERE, |
226 |
+ FROM_HERE, |
227 |
+ base::BindOnce(&BlockingTaskHelper::GetFeatureReport, |
227 |
+ base::BindOnce(&BlockingTaskRunnerHelper::GetFeatureReport, |
228 |
+ base::Unretained(helper_.get()), report_id, |
228 |
+ base::Unretained(helper_.get()), report_id, |
229 |
+ buffer, std::move(callback))); |
229 |
+ buffer, std::move(callback))); |
230 |
+} |
230 |
+} |
Lines 236-242
Link Here
|
236 |
+ FROM_HERE, base::BlockingType::MAY_BLOCK); |
236 |
+ FROM_HERE, base::BlockingType::MAY_BLOCK); |
237 |
+ blocking_task_runner_->PostTask( |
237 |
+ blocking_task_runner_->PostTask( |
238 |
+ FROM_HERE, |
238 |
+ FROM_HERE, |
239 |
+ base::BindOnce(&BlockingTaskHelper::SendFeatureReport, |
239 |
+ base::BindOnce(&BlockingTaskRunnerHelper::SendFeatureReport, |
240 |
+ base::Unretained(helper_.get()), buffer, std::move(callback))); |
240 |
+ base::Unretained(helper_.get()), buffer, std::move(callback))); |
241 |
+} |
241 |
+} |
242 |
+ |
242 |
+ |