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

Unified Diff: content/renderer/usb/web_usb_device_impl.cc

Issue 1358763004: Implement getConfiguration in WebUSBDeviceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « content/renderer/usb/web_usb_device_impl.h ('k') | device/devices_app/usb/device_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/usb/web_usb_device_impl.cc
diff --git a/content/renderer/usb/web_usb_device_impl.cc b/content/renderer/usb/web_usb_device_impl.cc
index 8ccebdc6bbb1c8b53509a072b0d68695c51bd160..46c4fba950eeceacfe880a861ccb8e82c7bd0580 100644
--- a/content/renderer/usb/web_usb_device_impl.cc
+++ b/content/renderer/usb/web_usb_device_impl.cc
@@ -23,6 +23,7 @@ namespace {
const char kClaimInterfaceFailed[] = "Unable to claim interface.";
const char kClearHaltFailed[] = "Unable to clear endpoint.";
const char kDeviceNoAccess[] = "Access denied.";
+const char kDeviceNotConfigured[] = "Device not configured.";
const char kDeviceNotOpened[] = "Device not opened.";
const char kDeviceUnavailable[] = "Device unavailable.";
const char kDeviceResetFailed[] = "Unable to reset the device.";
@@ -90,6 +91,16 @@ void OnDeviceClosed(
callbacks.PassCallbacks()->onSuccess();
}
+void OnGetConfiguration(
+ ScopedWebCallbacks<blink::WebUSBDeviceGetConfigurationCallbacks> callbacks,
+ uint8_t configuration_value) {
+ auto scoped_callbacks = callbacks.PassCallbacks();
+ if (configuration_value == 0)
+ RejectWithDeviceError(kDeviceNotConfigured, scoped_callbacks.Pass());
+ else
+ scoped_callbacks->onSuccess(configuration_value);
+}
+
void HandlePassFailDeviceOperation(
ScopedWebCallbacks<blink::WebCallbacks<void, const blink::WebUSBError&>>
callbacks,
@@ -171,6 +182,17 @@ void WebUSBDeviceImpl::close(blink::WebUSBDeviceCloseCallbacks* callbacks) {
}
}
+void WebUSBDeviceImpl::getConfiguration(
+ blink::WebUSBDeviceGetConfigurationCallbacks* callbacks) {
+ auto scoped_callbacks = MakeScopedUSBCallbacks(callbacks);
+ if (!device_) {
+ RejectWithDeviceError(kDeviceNotOpened, scoped_callbacks.PassCallbacks());
+ } else {
+ device_->GetConfiguration(
+ base::Bind(&OnGetConfiguration, base::Passed(&scoped_callbacks)));
+ }
+}
+
void WebUSBDeviceImpl::setConfiguration(
uint8_t configuration_value,
blink::WebUSBDeviceSetConfigurationCallbacks* callbacks) {
« no previous file with comments | « content/renderer/usb/web_usb_device_impl.h ('k') | device/devices_app/usb/device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698