Skip to content

Commit

Permalink
USB/WebUSB documentation, adding README.md files in several locations.
Browse files Browse the repository at this point in the history
Bug: 740070
Change-Id: I9d0a7371c22856a641ad88910d55ba844aca4191
Reviewed-on: https://chromium-review.googlesource.com/572332
Commit-Queue: Vincent Scheib <scheib@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488481}
  • Loading branch information
scheib authored and Commit Bot committed Jul 20, 2017
1 parent babe3ef commit 42d2353
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
53 changes: 53 additions & 0 deletions device/usb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# USB

`device/usb` abstracts [Universal Serial Bus](https://en.wikipedia.org/wiki/USB)
concepts across multiple platforms.

Clients should use the [public Mojo interface](/device/usb/public/interfaces).


## USB ID Repository

`/third_party/usb_ids/usb.ids` is imported regularly to provide human-readable
descriptions of USB devices.


## Ongoing Work transitioning away from `libusb`

`UsbService` is implemented by `UsbServiceImpl` based on `third_party/libusb`.

Work is ongoing to implement each platform directly, without using `libusb`.

* `UsbServiceAndroid` done.
* `UsbServiceLinux` done.
* macOS not started.
* `UsbServiceWin` in progress. Enable via `chrome://flags/#new-usb-backend`


## Testing

### Unit Tests

Standard use of `*_unittest.cc` files for must code coverage.


### Fuzzers

[libFuzzer] tests are in `*_fuzzer.cc` files. They test for bad input from
devices, e.g. when parsing device descriptors during device enumeration.

[libFuzzer]: /testing/libfuzzer/README.md


### Gadget Tests

[USB/HID API Testing with Gadgets] describes a framework for testing the Chrome
USB, HID and serial device APIs with real devices on generally accessible
hardware.

[USB/HID API Testing with Gadgets]: https://docs.google.com/document/d/1O9jTlOAyeCwZX_XRbmQmNFidcJo8QZQSaodP-wmyess

Unit tests using the gadget can be run manually with a hardware "gadget". These
unit tests all call [UsbTestGadget::Claim].

[UsbTestGadget::Claim]: https://cs.chromium.org/search/?q=UsbTestGadget::Claim&type=cs
4 changes: 2 additions & 2 deletions device/usb/mojo/device_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace usb {

class PermissionProvider;

// Implementation of the public DeviceManager interface. This interface can be
// requested from the devices app located at "devices", if available.
// Implements the public Mojo UsbDeviceManager interface by wrapping the
// UsbService instance.
class DeviceManagerImpl : public mojom::UsbDeviceManager,
public UsbService::Observer {
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This directory contains Chromium-specific test resources.

The files `mojo_bindings.js` and `*.mojom.js` are automatically generated by the
Chromium build process and should not be edited manually.
The files `mojo_bindings.js` and `*.mojom.js` are manually copied from the
Chromium build process's generated files and should not be edited manually.
12 changes: 12 additions & 0 deletions third_party/WebKit/LayoutTests/external/wpt/webusb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# WebUSB Testing

WebUSB testing relies on the [WebUSB Testing API] which must be
provided by browsers under test.

In this test suite `resources/usb-helpers.js` detects and triggers
the API to be loaded as needed.

The Chromium implementation is provided by
`../resources/chromium/webusb-test.js`.

[WebUSB Testing API]: https://wicg.github.io/webusb/test/
17 changes: 17 additions & 0 deletions third_party/WebKit/Source/modules/webusb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# WebUSB Blink Module

`Source/modules/webusb` implements the renderer process details and bindings
for the [WebUSB specification]. It communicates with the browser process through the [public Mojo interface] of `//device/usb` to the [UsbService].

[WebUSB specification]: https://wicg.github.io/webusb/
[public Mojo interface]: /device/usb/public/interfaces
[UsbService]: /device/usb/usb_service.h


## Testing

WebUSB is primarily tested in [Web Platform Tests].
Chromium implementation details are tested in [Layout Tests].

[Web Platform Tests]: ../../../LayoutTests/external/wpt/webusb/
[Layout Tests]: ../../../LayoutTests/usb/

0 comments on commit 42d2353

Please sign in to comment.