Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: components/usb_service/usb_device_impl.cc

Issue 344793009: Log errors from libusb. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/usb_service/usb_device_handle_impl.cc ('k') | components/usb_service/usb_error.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/usb_service/usb_device_impl.cc
diff --git a/components/usb_service/usb_device_impl.cc b/components/usb_service/usb_device_impl.cc
index 43c8c66fbd43ad92dcb0cbaa2f6b481315eeded4..bbae9c8a4bc45937a5403af7fa5d1112191baf9f 100644
--- a/components/usb_service/usb_device_impl.cc
+++ b/components/usb_service/usb_device_impl.cc
@@ -9,6 +9,7 @@
#include "base/stl_util.h"
#include "components/usb_service/usb_context.h"
#include "components/usb_service/usb_device_handle_impl.h"
+#include "components/usb_service/usb_error.h"
#include "components/usb_service/usb_interface_impl.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/libusb/src/libusb/libusb.h"
@@ -93,7 +94,7 @@ void UsbDeviceImpl::RequestUsbAcess(
scoped_refptr<UsbDeviceHandle> UsbDeviceImpl::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
PlatformUsbDeviceHandle handle;
- int rv = libusb_open(platform_device_, &handle);
+ const int rv = libusb_open(platform_device_, &handle);
if (LIBUSB_SUCCESS == rv) {
scoped_refptr<UsbConfigDescriptor> interfaces = ListInterfaces();
if (!interfaces)
@@ -102,8 +103,10 @@ scoped_refptr<UsbDeviceHandle> UsbDeviceImpl::Open() {
new UsbDeviceHandleImpl(context_, this, handle, interfaces);
handles_.push_back(device_handle);
return device_handle;
+ } else {
+ LOG(ERROR) << "Failed to open device: " << ConvertErrorToString(rv);
+ return NULL;
}
- return NULL;
}
bool UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) {
@@ -124,12 +127,15 @@ scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() {
DCHECK(thread_checker_.CalledOnValidThread());
PlatformUsbConfigDescriptor platform_config;
- const int list_result =
+ const int rv =
libusb_get_active_config_descriptor(platform_device_, &platform_config);
- if (list_result == 0)
+ if (rv == LIBUSB_SUCCESS) {
return new UsbConfigDescriptorImpl(platform_config);
-
- return NULL;
+ } else {
+ LOG(ERROR) << "Failed to get config descriptor: "
+ << ConvertErrorToString(rv);
+ return NULL;
+ }
}
void UsbDeviceImpl::OnDisconnect() {
« no previous file with comments | « components/usb_service/usb_device_handle_impl.cc ('k') | components/usb_service/usb_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698