mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Step annotations for WebBluetooth functions
This commit is contained in:
parent
89c4219a36
commit
8dd100f74f
7 changed files with 367 additions and 34 deletions
|
@ -79,7 +79,7 @@ impl<Listener: AsyncBluetoothListener + Reflectable> BluetoothResponseListener f
|
|||
match response {
|
||||
Ok(response) => self.receiver.root().handle_response(response, promise_cx, &promise),
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||
// Step 3-4.
|
||||
// Step 3 - 4.
|
||||
Err(error) => promise.reject_error(promise_cx, Error::from(error)),
|
||||
}
|
||||
}
|
||||
|
@ -187,9 +187,9 @@ impl Bluetooth {
|
|||
let option = RequestDeviceoptions::new(BluetoothScanfilterSequence::new(uuid_filters),
|
||||
ServiceUUIDSequence::new(optional_services_uuids));
|
||||
|
||||
// TODO: Step 3-5: Implement the permission API.
|
||||
// TODO: Step 3 - 5: Implement the permission API.
|
||||
|
||||
// Note: Steps 6-8 are implemented in
|
||||
// Note: Steps 6 - 8 are implemented in
|
||||
// components/net/bluetooth_thread.rs in request_device function.
|
||||
let sender = response_async(p, self);
|
||||
self.get_bluetooth_thread().send(BluetoothRequest::RequestDevice(option, sender)).unwrap();
|
||||
|
@ -295,7 +295,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
None => String::new(),
|
||||
};
|
||||
|
||||
// Step 6 -7.
|
||||
// Step 6 - 7.
|
||||
let manufacturer_data = match filter.manufacturerData {
|
||||
Some(ref manufacturer_data_map) => {
|
||||
// Note: If manufacturer_data_map is empty, that means there are no key values in it.
|
||||
|
@ -304,7 +304,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
}
|
||||
let mut map = HashMap::new();
|
||||
for (key, bdfi) in manufacturer_data_map.iter() {
|
||||
// Step 7.1-7.2.
|
||||
// Step 7.1 - 7.2.
|
||||
let manufacturer_id = match u16::from_str(key.as_ref()) {
|
||||
Ok(id) => id,
|
||||
Err(err) => return Err(Type(format!("{} {} {}", KEY_CONVERSION_ERROR, key, err))),
|
||||
|
@ -312,7 +312,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
|
||||
// Step 7.3: No need to convert to IDL values since this is only used by native code.
|
||||
|
||||
// Step 7.4 -7.5.
|
||||
// Step 7.4 - 7.5.
|
||||
map.insert(manufacturer_id, try!(canonicalize_bluetooth_data_filter_init(bdfi)));
|
||||
}
|
||||
Some(map)
|
||||
|
@ -320,7 +320,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
None => None,
|
||||
};
|
||||
|
||||
// Step 8-9.
|
||||
// Step 8 - 9.
|
||||
let service_data = match filter.serviceData {
|
||||
Some(ref service_data_map) => {
|
||||
// Note: If service_data_map is empty, that means there are no key values in it.
|
||||
|
@ -336,7 +336,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
_ => StringOrUnsignedLong::String(key.clone())
|
||||
};
|
||||
|
||||
// Step 9.3-9.4.
|
||||
// Step 9.3 - 9.4.
|
||||
let service = try!(BluetoothUUID::service(service_name)).to_string();
|
||||
|
||||
// Step 9.5.
|
||||
|
@ -346,7 +346,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
|||
|
||||
// Step 9.6: No need to convert to IDL values since this is only used by native code.
|
||||
|
||||
// Step 9.7 -9.8.
|
||||
// Step 9.7 - 9.8.
|
||||
map.insert(service, try!(canonicalize_bluetooth_data_filter_init(bdfi)));
|
||||
}
|
||||
Some(map)
|
||||
|
@ -404,7 +404,7 @@ impl BluetoothMethods for Bluetooth {
|
|||
|
||||
// Step 2.
|
||||
self.request_bluetooth_devices(&p, &option.filters, &option.optionalServices);
|
||||
//Note: Step 3-4. in response function, Step 5. in handle_response function.
|
||||
//Note: Step 3 - 4. in response function, Step 5. in handle_response function.
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ impl AsyncBluetoothListener for Bluetooth {
|
|||
fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
|
||||
match response {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
||||
// Step 13-14.
|
||||
// Step 13 - 14.
|
||||
BluetoothResponse::RequestDevice(device) => {
|
||||
let mut device_instance_map = self.device_instance_map.borrow_mut();
|
||||
if let Some(existing_device) = device_instance_map.get(&device.id.clone()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue