| Index: device/hid/hid_service_mac.cc
|
| diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc
|
| index de6861de676ca45a012270b41939625a39cb0469..dec4e70a1153e0b7e476a0dc7349afc38784aa48 100644
|
| --- a/device/hid/hid_service_mac.cc
|
| +++ b/device/hid/hid_service_mac.cc
|
| @@ -21,12 +21,17 @@
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "base/threading/thread_restrictions.h"
|
| +#include "components/device_event_log/device_event_log.h"
|
| #include "device/hid/hid_connection_mac.h"
|
|
|
| namespace device {
|
|
|
| namespace {
|
|
|
| +std::string HexErrorCode(IOReturn error_code) {
|
| + return base::StringPrintf("0x%04x", error_code);
|
| +}
|
| +
|
| bool TryGetHidIntProperty(IOHIDDeviceRef device,
|
| CFStringRef key,
|
| int32_t* result) {
|
| @@ -96,8 +101,8 @@ HidServiceMac::HidServiceMac(
|
| this,
|
| &iterator);
|
| if (result != kIOReturnSuccess) {
|
| - LOG(ERROR) << "Failed to listen for device arrival: "
|
| - << base::StringPrintf("0x%04x", result);
|
| + HID_LOG(ERROR) << "Failed to listen for device arrival: "
|
| + << HexErrorCode(result);
|
| return;
|
| }
|
|
|
| @@ -113,8 +118,8 @@ HidServiceMac::HidServiceMac(
|
| this,
|
| &iterator);
|
| if (result != kIOReturnSuccess) {
|
| - LOG(ERROR) << "Failed to listen for device removal: "
|
| - << base::StringPrintf("0x%04x", result);
|
| + HID_LOG(ERROR) << "Failed to listen for device removal: "
|
| + << HexErrorCode(result);
|
| return;
|
| }
|
|
|
| @@ -140,7 +145,7 @@ void HidServiceMac::Connect(const HidDeviceId& device_id,
|
| base::mac::ScopedIOObject<io_service_t> service(
|
| IORegistryEntryFromPath(kIOMasterPortDefault, service_path));
|
| if (!service.get()) {
|
| - VLOG(1) << "IOService not found for path: " << device_id;
|
| + HID_LOG(EVENT) << "IOService not found for path: " << device_id;
|
| task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
|
| return;
|
| }
|
| @@ -148,15 +153,14 @@ void HidServiceMac::Connect(const HidDeviceId& device_id,
|
| base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device(
|
| IOHIDDeviceCreate(kCFAllocatorDefault, service));
|
| if (!hid_device) {
|
| - VLOG(1) << "Unable to create IOHIDDevice object.";
|
| + HID_LOG(EVENT) << "Unable to create IOHIDDevice object.";
|
| task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
|
| return;
|
| }
|
|
|
| IOReturn result = IOHIDDeviceOpen(hid_device, kIOHIDOptionsTypeNone);
|
| if (result != kIOReturnSuccess) {
|
| - VLOG(1) << "Failed to open device: " << base::StringPrintf("0x%04x",
|
| - result);
|
| + HID_LOG(EVENT) << "Failed to open device: " << HexErrorCode(result);
|
| task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
|
| return;
|
| }
|
| @@ -229,23 +233,23 @@ scoped_refptr<HidDeviceInfo> HidServiceMac::CreateDeviceInfo(
|
| IOReturn result =
|
| IORegistryEntryGetPath(service, kIOServicePlane, service_path);
|
| if (result != kIOReturnSuccess) {
|
| - VLOG(1) << "Failed to get IOService path: " << base::StringPrintf("0x%04x",
|
| - result);
|
| + HID_LOG(EVENT) << "Failed to get IOService path: " << HexErrorCode(result);
|
| return nullptr;
|
| }
|
|
|
| base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device(
|
| IOHIDDeviceCreate(kCFAllocatorDefault, service));
|
| if (!hid_device) {
|
| - VLOG(1) << "Unable to create IOHIDDevice object for " << service_path
|
| - << ".";
|
| + HID_LOG(EVENT) << "Unable to create IOHIDDevice object for " << service_path
|
| + << ".";
|
| return nullptr;
|
| }
|
|
|
| std::vector<uint8> report_descriptor;
|
| if (!TryGetHidDataProperty(hid_device, CFSTR(kIOHIDReportDescriptorKey),
|
| &report_descriptor)) {
|
| - VLOG(1) << "Unable to get report descriptor for " << service_path << ".";
|
| + HID_LOG(EVENT) << "Unable to get report descriptor for " << service_path
|
| + << ".";
|
| return nullptr;
|
| }
|
|
|
|
|