-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Implement GetAvailability for Bluetooth #15368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
☔ The latest upstream changes (presumably #15367) made this pull request unmergeable. Please resolve the merge conflicts. |
72a23d3
to
87a1712
Compare
components/script/dom/bluetooth.rs
Outdated
let sender = response_async(&p, self); | ||
self.get_bluetooth_thread().send( | ||
BluetoothRequest::GetAvailability(sender)).unwrap(); | ||
return p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
is useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to change this.
@@ -443,6 +443,18 @@ impl BluetoothMethods for Bluetooth { | |||
return p; | |||
} | |||
|
|||
#[allow(unrooted_must_root)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required for the Rc<Promise>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdm That sounds very weird, why does Rc<Promise>
need unrooted_must_root
be allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because our rooting lint doesn't understand that Rc<Promise>
is safe. I thought there was an issue about it, but I can't find it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -924,4 +927,12 @@ impl BluetoothManager { | |||
// TODO: Implement this when supported in lower level | |||
return Err(BluetoothError::NotSupported); | |||
} | |||
|
|||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability | |||
fn get_availability(&mut self) -> BluetoothResponseResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this return a Result
? It doesn't seem to return any error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called via an async promise and the handle function requires a result, because usually a promise could fail, but this will only resolve. Step 2 - 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
components/bluetooth/lib.rs
Outdated
match self.get_adapter() { | ||
Ok(_) => Ok(BluetoothResponse::GetAvailability(true)), | ||
Err(_) => Ok(BluetoothResponse::GetAvailability(false)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BluetoothResponse::GetAvailability(self.get_adapter().is_ok())
☔ The latest upstream changes (presumably #15405) made this pull request unmergeable. Please resolve the merge conflicts. |
87a1712
to
8e2201e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash and remove that superfluous return
.
@@ -443,6 +443,18 @@ impl BluetoothMethods for Bluetooth { | |||
return p; | |||
} | |||
|
|||
#[allow(unrooted_must_root)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
components/script/dom/bluetooth.rs
Outdated
let sender = response_async(&p, self); | ||
self.get_bluetooth_thread().send( | ||
BluetoothRequest::GetAvailability(sender)).unwrap(); | ||
return p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to change this.
8e2201e
to
ca7aa6b
Compare
@bors-servo r+ |
📌 Commit ca7aa6b has been approved by |
Implement GetAvailability for Bluetooth <!-- Please describe your changes on the following line: --> This implements the [getAvailability](https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability) function from the spec. --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15368) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
This implements the getAvailability function from the spec.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is