diff options
author | reillyg <reillyg@chromium.org> | 2015-02-23 17:28:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-24 01:29:27 +0000 |
commit | b9da284b42d4a3b9498d64f1c61452c5f5ae4ff2 (patch) | |
tree | 02220b4e22f2bbc7e5ee1db5797719f03133f72f /device/hid/hid_connection_mac.cc | |
parent | 202524aacb06c948a3f4a34f4418f32b550c79b5 (diff) | |
download | chromium_src-b9da284b42d4a3b9498d64f1c61452c5f5ae4ff2.zip chromium_src-b9da284b42d4a3b9498d64f1c61452c5f5ae4ff2.tar.gz chromium_src-b9da284b42d4a3b9498d64f1c61452c5f5ae4ff2.tar.bz2 |
Log device/hid messages to chrome://device-log.
Log events and debugging information related to HID devices through the
device event log component so that these errors are visible at
chrome://device-log. A DEVICE_PLOG macro has been added which includes
the last reported system error in the log message.
BUG=448901
Review URL: https://codereview.chromium.org/947663002
Cr-Commit-Position: refs/heads/master@{#317722}
Diffstat (limited to 'device/hid/hid_connection_mac.cc')
-rw-r--r-- | device/hid/hid_connection_mac.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/device/hid/hid_connection_mac.cc b/device/hid/hid_connection_mac.cc index fe485f7..de93cc6 100644 --- a/device/hid/hid_connection_mac.cc +++ b/device/hid/hid_connection_mac.cc @@ -10,10 +10,19 @@ #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/thread_task_runner_handle.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); +} + +} // namespace + HidConnectionMac::HidConnectionMac( IOHIDDeviceRef device, scoped_refptr<HidDeviceInfo> device_info, @@ -59,8 +68,7 @@ void HidConnectionMac::PlatformClose() { device_.get(), CFRunLoopGetMain(), kCFRunLoopDefaultMode); IOReturn result = IOHIDDeviceClose(device_.get(), 0); if (result != kIOReturnSuccess) { - VLOG(1) << "Failed to close HID device: " - << base::StringPrintf("0x%04x", result); + HID_LOG(EVENT) << "Failed to close HID device: " << HexErrorCode(result); } while (!pending_reads_.empty()) { @@ -120,8 +128,7 @@ void HidConnectionMac::InputReportCallback(void* context, CFIndex report_length) { HidConnectionMac* connection = static_cast<HidConnectionMac*>(context); if (result != kIOReturnSuccess) { - VLOG(1) << "Failed to read input report: " - << base::StringPrintf("0x%08x", result); + HID_LOG(EVENT) << "Failed to read input report: " << HexErrorCode(result); return; } @@ -186,8 +193,7 @@ void HidConnectionMac::GetFeatureReportAsync(uint8_t report_id, this, base::Bind(callback, true, buffer, report_size))); } else { - VLOG(1) << "Failed to get feature report: " - << base::StringPrintf("0x%08x", result); + HID_LOG(EVENT) << "Failed to get feature report: " << HexErrorCode(result); task_runner_->PostTask(FROM_HERE, base::Bind(&HidConnectionMac::ReturnAsyncResult, this, @@ -222,7 +228,7 @@ void HidConnectionMac::SetReportAsync(IOHIDReportType report_type, this, base::Bind(callback, true))); } else { - VLOG(1) << "Failed to set report: " << base::StringPrintf("0x%08x", result); + HID_LOG(EVENT) << "Failed to set report: " << HexErrorCode(result); task_runner_->PostTask(FROM_HERE, base::Bind(&HidConnectionMac::ReturnAsyncResult, this, |