mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Replace use of callbacks in webxr by channels
This commit is contained in:
parent
5c8fee4e0b
commit
133a17e15c
11 changed files with 109 additions and 190 deletions
|
@ -73,20 +73,6 @@ impl XRTest {
|
|||
impl XRTestMethods for XRTest {
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SimulateDeviceConnection(&self, init: &FakeXRDeviceInit) -> Rc<Promise> {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct MockDevice {
|
||||
sender: IpcSender<Result<IpcSender<MockDeviceMsg>, XRError>>,
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl webxr_api::MockDeviceCallback for MockDevice {
|
||||
fn callback(&mut self, result: Result<IpcSender<MockDeviceMsg>, XRError>) {
|
||||
self.sender
|
||||
.send(result)
|
||||
.expect("mock device callback failed");
|
||||
}
|
||||
}
|
||||
|
||||
let p = Promise::new(&self.global());
|
||||
|
||||
if !init.supportsImmersive || self.session_started.get() {
|
||||
|
@ -166,7 +152,7 @@ impl XRTestMethods for XRTest {
|
|||
);
|
||||
window
|
||||
.webxr_registry()
|
||||
.simulate_device_connection(init, MockDevice { sender });
|
||||
.simulate_device_connection(init, sender);
|
||||
|
||||
p
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue