| Index: chrome/browser/extensions/api/usb/usb_api.cc
|
| diff --git a/chrome/browser/extensions/api/usb/usb_api.cc b/chrome/browser/extensions/api/usb/usb_api.cc
|
| index e6ca32719227234f0c338b134e3f11198121cd34..f6bf5c174408d1beb05f4bb4926e4f2c7bec0f16 100644
|
| --- a/chrome/browser/extensions/api/usb/usb_api.cc
|
| +++ b/chrome/browser/extensions/api/usb/usb_api.cc
|
| @@ -59,6 +59,8 @@ namespace {
|
| const char kDataKey[] = "data";
|
| const char kResultCodeKey[] = "resultCode";
|
|
|
| +const char kErrorInitService[] = "Failed to initialize USB service.";
|
| +
|
| const char kErrorOpen[] = "Failed to open device.";
|
| const char kErrorCancelled[] = "Transfer was cancelled.";
|
| const char kErrorDisconnect[] = "Device disconnected.";
|
| @@ -412,6 +414,10 @@ UsbAsyncApiFunction::GetDeviceOrOrCompleteWithError(
|
| }
|
|
|
| UsbService* service = UsbService::GetInstance();
|
| + if (!service) {
|
| + CompleteWithError(kErrorInitService);
|
| + return NULL;
|
| + }
|
| scoped_refptr<UsbDevice> device;
|
|
|
| device = service->GetDeviceById(input_device.device);
|
| @@ -537,6 +543,11 @@ void UsbFindDevicesFunction::AsyncWorkStart() {
|
| }
|
|
|
| UsbService *service = UsbService::GetInstance();
|
| + if (!service) {
|
| + CompleteWithError(kErrorInitService);
|
| + return;
|
| + }
|
| +
|
| ScopedDeviceVector devices(new DeviceVector());
|
| service->GetDevices(devices.get());
|
|
|
| @@ -624,6 +635,11 @@ void UsbGetDevicesFunction::AsyncWorkStart() {
|
| }
|
|
|
| UsbService* service = UsbService::GetInstance();
|
| + if (!service) {
|
| + CompleteWithError(kErrorInitService);
|
| + return;
|
| + }
|
| +
|
| DeviceVector devices;
|
| service->GetDevices(&devices);
|
|
|
|
|