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

Unified Diff: public/platform/modules/webusb/WebUSBDevice.h

Issue 1264483005: Add WebUSB bindings and client interface [part 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove CallbackPromiseAdapter usage Created 5 years, 5 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
Index: public/platform/modules/webusb/WebUSBDevice.h
diff --git a/public/platform/modules/webusb/WebUSBDevice.h b/public/platform/modules/webusb/WebUSBDevice.h
new file mode 100644
index 0000000000000000000000000000000000000000..1550b587da9bb629fca6c5aae8e0b274cffa152a
--- /dev/null
+++ b/public/platform/modules/webusb/WebUSBDevice.h
@@ -0,0 +1,105 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WebUSBDevice_h
+#define WebUSBDevice_h
+
+#include "public/platform/WebCallbacks.h"
+#include "public/platform/WebVector.h"
+
+namespace blink {
+
+struct WebUSBDeviceInfo;
+struct WebUSBError;
+struct WebUSBTransferInfo;
+
+using WebUSBDeviceOpenCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceCloseCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceResetCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, WebUSBError*>;
+using WebUSBDeviceControlTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebUSBError*>;
+using WebUSBDeviceBulkTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebUSBError*>;
+using WebUSBDeviceInterruptTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebUSBError*>;
+
+class WebUSBDevice {
+public:
+ enum TransferDirection {
dcheng 2015/07/31 18:58:25 enum class
Ken Rockot(use gerrit already) 2015/07/31 19:14:28 Done.
+ TransferDirectionIn,
+ TransferDirectionOut
+ };
+
+ enum RequestType {
dcheng 2015/07/31 18:58:24 enum class
Ken Rockot(use gerrit already) 2015/07/31 19:14:28 Done.
+ RequestTypeStandard,
dcheng 2015/07/31 18:58:24 Then you can just call this "Standard", "Class", "
Ken Rockot(use gerrit already) 2015/07/31 19:14:28 Done.
+ RequestTypeClass,
+ RequestTypeVendor,
+ };
+
+ enum RequestRecipient {
dcheng 2015/07/31 18:58:24 enum class
Ken Rockot(use gerrit already) 2015/07/31 19:14:28 Done.
+ RequestRecipientDevice,
+ RequestRecipientInterface,
+ RequestRecipientEndpoint,
+ RequestRecipientOther,
+ };
+
+ struct ControlTransferParameters {
+ TransferDirection direction;
+ RequestType type;
+ RequestRecipient recipient;
+ uint8_t request;
+ uint16_t value;
+ uint16_t index;
+ };
+
+ virtual ~WebUSBDevice() { }
+
+ virtual const WebUSBDeviceInfo& info() const = 0;
+
+ // Opens the device.
+ // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client.
+ virtual void open(WebUSBDeviceOpenCallbacks*) = 0;
+
+ // Closes the device.
+ // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client.
+ virtual void close(WebUSBDeviceCloseCallbacks*) = 0;
+
+ // Sets the active configuration for the device.
+ // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client.
+ virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetConfigurationCallbacks*) = 0;
+
+ // Claims an interface in the active configuration.
+ // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to the client.
+ virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterfaceCallbacks*) = 0;
+
+ // Releases a claimed interface.
+ // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client.
+ virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseInterfaceCallbacks*) = 0;
+
+ // Sets the alternate setting of an interface.
+ // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is transferred to the client.
+ virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0;
+
+ // Clears the halt condition on a specific endpoint.
+ // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the client.
+ virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallbacks*) = 0;
+
+ // Initiates a control transfer.
+ // Ownership of the WebUSBDeviceControlTransferCallbacks is transferred to the client.
+ virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data, size_t dataSize, unsigned timeout, WebUSBDeviceControlTransferCallbacks*) = 0;
+
+ // Initiates a bulk or interrupt transfer.
+ // Ownership of the WebUSBDeviceBulkTransferCallbacks is transferred to the client.
+ virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* data, size_t dataSize, unsigned timeout, WebUSBDeviceBulkTransferCallbacks*) = 0;
+
+ // Resets the device.
+ // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client.
+ virtual void reset(WebUSBDeviceResetCallbacks*) = 0;
+};
+
+} // namespace blink
+
+#endif // WebUSBDevice_h

Powered by Google App Engine
This is Rietveld 408576698