Auto merge of #13184 - szeged:requestdevice-refactor, r=jdm

Webbluetooth requestDevice refactor and update

<!-- Please describe your changes on the following line: -->
Refactor requestDevice function according to the specification changes.
1. Moved the `request_bluetooth_devices` algorithm out from the `requestDevice` function.
2. Two new members in `BluetoothRequestDeviceFilter` and one new member in `RequestDeviceOptions`.
3. Also added annotations to the related functions.
Related links:
https://webbluetoothcg.github.io/web-bluetooth/#device-discovery,
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice, https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices,
https://webbluetoothcg.github.io/web-bluetooth/#matches-a-filter

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12614

<!-- Either: -->
- [x] These changes do not require tests because , there is no WebBluetooth Test API implementation yet.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13184)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-15 17:29:44 -05:00 committed by GitHub
commit 8334020a87
5 changed files with 306 additions and 100 deletions

View file

@ -4,24 +4,31 @@
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
dictionary BluetoothScanFilter {
dictionary BluetoothRequestDeviceFilter {
sequence<BluetoothServiceUUID> services;
DOMString name;
DOMString namePrefix;
unsigned short manufacturerId;
BluetoothServiceUUID serviceDataUUID;
};
dictionary RequestDeviceOptions {
required sequence<BluetoothScanFilter> filters;
sequence<BluetoothRequestDeviceFilter> filters;
sequence<BluetoothServiceUUID> optionalServices /*= []*/;
boolean acceptAllDevices = false;
};
[Pref="dom.bluetooth.enabled", Exposed=(Window,Worker)]
interface Bluetooth {
// Promise<BluetoothDevice> requestDevice(RequestDeviceOptions options);
[Throws]
BluetoothDevice requestDevice(RequestDeviceOptions options);
// [SecureContext]
// readonly attribute BluetoothDevice? referringDevice;
// [SecureContext]
// Promise<BluetoothDevice> requestDevice(RequestDeviceOptions options);
[Throws]
BluetoothDevice requestDevice(optional RequestDeviceOptions options);
};
// Bluetooth implements EventTarget;
// Bluetooth implements BluetoothDeviceEventHandlers;
// Bluetooth implements CharacteristicEventHandlers;
// Bluetooth implements ServiceEventHandlers;