Chromium Code Reviews| Index: device/usb/usb_device_handle_impl.cc |
| diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc |
| index c64931c7cba6768c7756fbf06082c2094cde4740..823786b190a7d6de2a7ee9f5cbe86fc7c99ed406 100644 |
| --- a/device/usb/usb_device_handle_impl.cc |
| +++ b/device/usb/usb_device_handle_impl.cc |
| @@ -18,6 +18,7 @@ |
| #include "device/usb/usb_descriptors.h" |
| #include "device/usb/usb_device_impl.h" |
| #include "device/usb/usb_error.h" |
| +#include "device/usb/usb_log.h" |
| #include "device/usb/usb_service.h" |
| #include "third_party/libusb/src/libusb/libusb.h" |
| @@ -145,8 +146,8 @@ UsbDeviceHandleImpl::InterfaceClaimer::~InterfaceClaimer() { |
| bool UsbDeviceHandleImpl::InterfaceClaimer::Claim() const { |
| const int rv = libusb_claim_interface(handle_->handle(), interface_number_); |
| if (rv != LIBUSB_SUCCESS) { |
| - VLOG(1) << "Failed to claim interface: " |
| - << ConvertPlatformUsbErrorToString(rv); |
| + USB_LOG(DEBUG) << "Failed to claim interface " << interface_number_ << ": " |
| + << ConvertPlatformUsbErrorToString(rv); |
|
stevenjb
2015/02/20 00:01:27
You might want to use type EVENT here. DEBUG doesn
Reilly Grant (use Gerrit)
2015/02/20 00:10:22
Spamminess is somewhat controlled by the Chrome ap
|
| } |
| return rv == LIBUSB_SUCCESS; |
| } |
| @@ -233,7 +234,7 @@ UsbDeviceHandleImpl::Transfer::CreateControlTransfer( |
| transfer->platform_transfer_ = libusb_alloc_transfer(0); |
| if (!transfer->platform_transfer_) { |
| - LOG(ERROR) << "Failed to allocate control transfer."; |
| + USB_LOG(DEBUG) << "Failed to allocate control transfer."; |
|
stevenjb
2015/02/20 00:01:27
If LOG(ERROR) was correct before, this should also
|
| return nullptr; |
| } |
| @@ -261,7 +262,7 @@ UsbDeviceHandleImpl::Transfer::CreateBulkTransfer( |
| transfer->platform_transfer_ = libusb_alloc_transfer(0); |
| if (!transfer->platform_transfer_) { |
| - LOG(ERROR) << "Failed to allocate bulk transfer."; |
| + USB_LOG(DEBUG) << "Failed to allocate bulk transfer."; |
|
stevenjb
2015/02/20 00:01:27
Double check all of these for ERROR / USER / EVENT
|
| return nullptr; |
| } |
| @@ -288,7 +289,7 @@ UsbDeviceHandleImpl::Transfer::CreateInterruptTransfer( |
| transfer->platform_transfer_ = libusb_alloc_transfer(0); |
| if (!transfer->platform_transfer_) { |
| - LOG(ERROR) << "Failed to allocate interrupt transfer."; |
| + USB_LOG(DEBUG) << "Failed to allocate interrupt transfer."; |
| return nullptr; |
| } |
| @@ -320,7 +321,7 @@ UsbDeviceHandleImpl::Transfer::CreateIsochronousTransfer( |
| transfer->platform_transfer_ = libusb_alloc_transfer(packets); |
| if (!transfer->platform_transfer_) { |
| - LOG(ERROR) << "Failed to allocate isochronous transfer."; |
| + USB_LOG(DEBUG) << "Failed to allocate isochronous transfer."; |
| return nullptr; |
| } |
| @@ -370,8 +371,8 @@ bool UsbDeviceHandleImpl::Transfer::Submit( |
| if (rv == LIBUSB_SUCCESS) { |
| return true; |
| } else { |
| - VLOG(1) << "Failed to submit transfer: " |
| - << ConvertPlatformUsbErrorToString(rv); |
| + USB_LOG(DEBUG) << "Failed to submit transfer: " |
| + << ConvertPlatformUsbErrorToString(rv); |
| Complete(USB_TRANSFER_ERROR, 0); |
| return false; |
| } |
| @@ -525,8 +526,8 @@ bool UsbDeviceHandleImpl::SetConfiguration(int configuration_value) { |
| device_->RefreshConfiguration(); |
| RefreshEndpointMap(); |
| } else { |
| - VLOG(1) << "Failed to set configuration " << configuration_value << ": " |
| - << ConvertPlatformUsbErrorToString(rv); |
| + USB_LOG(DEBUG) << "Failed to set configuration " << configuration_value |
| + << ": " << ConvertPlatformUsbErrorToString(rv); |
| } |
| return rv == LIBUSB_SUCCESS; |
| } |
| @@ -585,9 +586,9 @@ bool UsbDeviceHandleImpl::SetInterfaceAlternateSetting( |
| alternate_setting); |
| RefreshEndpointMap(); |
| } else { |
| - VLOG(1) << "Failed to set interface (" << interface_number << ", " |
| - << alternate_setting |
| - << "): " << ConvertPlatformUsbErrorToString(rv); |
| + USB_LOG(DEBUG) << "Failed to set interface " << interface_number |
| + << " to alternate setting " << alternate_setting << ": " |
| + << ConvertPlatformUsbErrorToString(rv); |
| } |
| return rv == LIBUSB_SUCCESS; |
| } |
| @@ -599,8 +600,8 @@ bool UsbDeviceHandleImpl::ResetDevice() { |
| const int rv = libusb_reset_device(handle_); |
| if (rv != LIBUSB_SUCCESS) { |
| - VLOG(1) << "Failed to reset device: " |
| - << ConvertPlatformUsbErrorToString(rv); |
| + USB_LOG(DEBUG) << "Failed to reset device: " |
| + << ConvertPlatformUsbErrorToString(rv); |
| } |
| return rv == LIBUSB_SUCCESS; |
| } |
| @@ -629,21 +630,23 @@ bool UsbDeviceHandleImpl::GetStringDescriptor(uint8 string_id, |
| reinterpret_cast<unsigned char*>(&text[0]), |
| sizeof(text)); |
| if (size < 0) { |
| - VLOG(1) << "Failed to get string descriptor " << string_id << " (langid " |
| - << language_id << "): " << ConvertPlatformUsbErrorToString(size); |
| + USB_LOG(DEBUG) << "Failed to get string descriptor " << string_id |
| + << " (langid " << language_id |
| + << "): " << ConvertPlatformUsbErrorToString(size); |
| continue; |
| } else if (size < 2) { |
| - VLOG(1) << "String descriptor " << string_id << " (langid " << language_id |
| - << ") has no header."; |
| + USB_LOG(DEBUG) << "String descriptor " << string_id << " (langid " |
| + << language_id << ") has no header."; |
| continue; |
| // The first 2 bytes of the descriptor are the total length and type tag. |
| } else if ((text[0] & 0xff) != size) { |
| - VLOG(1) << "String descriptor " << string_id << " (langid " << language_id |
| - << ") size mismatch: " << (text[0] & 0xff) << " != " << size; |
| + USB_LOG(DEBUG) << "String descriptor " << string_id << " (langid " |
| + << language_id << ") size mismatch: " << (text[0] & 0xff) |
| + << " != " << size; |
| continue; |
| } else if ((text[0] >> 8) != LIBUSB_DT_STRING) { |
| - VLOG(1) << "String descriptor " << string_id << " (langid " << language_id |
| - << ") is not a string descriptor."; |
| + USB_LOG(DEBUG) << "String descriptor " << string_id << " (langid " |
| + << language_id << ") is not a string descriptor."; |
| continue; |
| } |
| @@ -666,7 +669,7 @@ void UsbDeviceHandleImpl::ControlTransfer(UsbEndpointDirection direction, |
| unsigned int timeout, |
| const UsbTransferCallback& callback) { |
| if (length > UINT16_MAX) { |
| - LOG(ERROR) << "Transfer too long."; |
| + USB_LOG(DEBUG) << "Transfer too long."; |
| callback.Run(USB_TRANSFER_ERROR, buffer, 0); |
| return; |
| } |
| @@ -699,7 +702,7 @@ void UsbDeviceHandleImpl::BulkTransfer(const UsbEndpointDirection direction, |
| const unsigned int timeout, |
| const UsbTransferCallback& callback) { |
| if (length > INT_MAX) { |
| - LOG(ERROR) << "Transfer too long."; |
| + USB_LOG(DEBUG) << "Transfer too long."; |
| callback.Run(USB_TRANSFER_ERROR, buffer, 0); |
| return; |
| } |
| @@ -719,7 +722,7 @@ void UsbDeviceHandleImpl::InterruptTransfer( |
| unsigned int timeout, |
| const UsbTransferCallback& callback) { |
| if (length > INT_MAX) { |
| - LOG(ERROR) << "Transfer too long."; |
| + USB_LOG(DEBUG) << "Transfer too long."; |
| callback.Run(USB_TRANSFER_ERROR, buffer, 0); |
| return; |
| } |
| @@ -741,7 +744,7 @@ void UsbDeviceHandleImpl::IsochronousTransfer( |
| const unsigned int timeout, |
| const UsbTransferCallback& callback) { |
| if (length > INT_MAX) { |
| - LOG(ERROR) << "Transfer too long."; |
| + USB_LOG(DEBUG) << "Transfer too long."; |
| callback.Run(USB_TRANSFER_ERROR, buffer, 0); |
| return; |
| } |
| @@ -827,19 +830,19 @@ bool UsbDeviceHandleImpl::GetSupportedLanguages() { |
| reinterpret_cast<unsigned char*>(&languages[0]), |
| sizeof(languages)); |
| if (size < 0) { |
| - VLOG(1) << "Failed to get list of supported languages: " |
| - << ConvertPlatformUsbErrorToString(size); |
| + USB_LOG(DEBUG) << "Failed to get list of supported languages: " |
| + << ConvertPlatformUsbErrorToString(size); |
| return false; |
| } else if (size < 2) { |
| - VLOG(1) << "String descriptor zero has no header."; |
| + USB_LOG(DEBUG) << "String descriptor zero has no header."; |
| return false; |
| // The first 2 bytes of the descriptor are the total length and type tag. |
| } else if ((languages[0] & 0xff) != size) { |
| - VLOG(1) << "String descriptor zero size mismatch: " << (languages[0] & 0xff) |
| - << " != " << size; |
| + USB_LOG(DEBUG) << "String descriptor zero size mismatch: " |
| + << (languages[0] & 0xff) << " != " << size; |
| return false; |
| } else if ((languages[0] >> 8) != LIBUSB_DT_STRING) { |
| - VLOG(1) << "String descriptor zero is not a string descriptor."; |
| + USB_LOG(DEBUG) << "String descriptor zero is not a string descriptor."; |
| return false; |
| } |