| 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_mac.h" | 5 #include "device/hid/hid_connection_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/device_event_log/device_event_log.h" | 14 #include "components/device_event_log/device_event_log.h" |
| 15 #include "device/hid/hid_connection_mac.h" | 15 #include "device/hid/hid_connection_mac.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 std::string HexErrorCode(IOReturn error_code) { | 21 std::string HexErrorCode(IOReturn error_code) { |
| 22 return base::StringPrintf("0x%04x", error_code); | 22 return base::StringPrintf("0x%04x", error_code); |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 HidConnectionMac::HidConnectionMac( | 27 HidConnectionMac::HidConnectionMac( |
| 28 IOHIDDeviceRef device, | 28 base::ScopedCFTypeRef<IOHIDDeviceRef> device, |
| 29 scoped_refptr<HidDeviceInfo> device_info, | 29 scoped_refptr<HidDeviceInfo> device_info, |
| 30 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 30 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) |
| 31 : HidConnection(device_info), | 31 : HidConnection(device_info), |
| 32 device_(device, base::scoped_policy::RETAIN), | 32 device_(std::move(device)), |
| 33 file_task_runner_(file_task_runner) { | 33 file_task_runner_(file_task_runner) { |
| 34 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 34 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 35 DCHECK(task_runner_.get()); | 35 DCHECK(task_runner_.get()); |
| 36 | 36 |
| 37 IOHIDDeviceScheduleWithRunLoop( | 37 IOHIDDeviceScheduleWithRunLoop( |
| 38 device_.get(), CFRunLoopGetMain(), kCFRunLoopDefaultMode); | 38 device_.get(), CFRunLoopGetMain(), kCFRunLoopDefaultMode); |
| 39 | 39 |
| 40 size_t expected_report_size = device_info->max_input_report_size(); | 40 size_t expected_report_size = device_info->max_input_report_size(); |
| 41 if (device_info->has_report_id()) { | 41 if (device_info->has_report_id()) { |
| 42 expected_report_size++; | 42 expected_report_size++; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 this, | 237 this, |
| 238 base::Bind(callback, false))); | 238 base::Bind(callback, false))); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 void HidConnectionMac::ReturnAsyncResult(const base::Closure& callback) { | 242 void HidConnectionMac::ReturnAsyncResult(const base::Closure& callback) { |
| 243 callback.Run(); | 243 callback.Run(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace device | 246 } // namespace device |
| OLD | NEW |