aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetoothremotegattserver.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-06 11:14:53 -0800
committerGitHub <noreply@github.com>2016-12-06 11:14:53 -0800
commit2e1c40ec360ece7165fec11810158bf925d322dc (patch)
tree2ad7b2082ccd66c2549e29a8fbb3869e2ace683a /components/script/dom/bluetoothremotegattserver.rs
parent73b6e705b4e18f53f36c8af98543dc2819764ef5 (diff)
parent92df1240f84700352f5afec94bd0e607693a0e24 (diff)
downloadservo-2e1c40ec360ece7165fec11810158bf925d322dc.tar.gz
servo-2e1c40ec360ece7165fec11810158bf925d322dc.zip
Auto merge of #14441 - szeged:attribute-instance-map, r=jdm
Move the AttributeInstanceMaps from bluetooth to bluetoothDevice. <!-- Please describe your changes on the following line: --> The previous implementation differed from the spec, because there was three maps instead of one. With this, they will be merged into one. Also this map has been moved from bluetooth to bluetoothDevice, because its make more sense to store it there. There is an issue about it [here](https://github.com/WebBluetoothCG/web-bluetooth/issues/330). --- <!-- 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 <!-- Either: --> - [X] There are tests for these changes <!-- 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/14441) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bluetoothremotegattserver.rs')
-rw-r--r--components/script/dom/bluetoothremotegattserver.rs31
1 files changed, 3 insertions, 28 deletions
diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs
index 275c7ff9841..f325414e230 100644
--- a/components/script/dom/bluetoothremotegattserver.rs
+++ b/components/script/dom/bluetoothremotegattserver.rs
@@ -11,10 +11,8 @@ use dom::bindings::error::Error::{self, Network, Security};
use dom::bindings::error::ErrorResult;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
-use dom::bindings::str::DOMString;
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothdevice::BluetoothDevice;
-use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
use dom::globalscope::GlobalScope;
use dom::promise::Promise;
@@ -200,6 +198,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ let device = self.Device();
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
BluetoothResponse::GATTServerConnect(connected) => {
@@ -213,17 +212,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
// Step 7.
BluetoothResponse::GetPrimaryService(service) => {
- let context = self.device.get().get_context();
- let mut service_map = context.get_service_map().borrow_mut();
- if let Some(existing_service) = service_map.get(&service.instance_id) {
- promise.resolve_native(promise_cx, &existing_service.get());
- }
- let bt_service = BluetoothRemoteGATTService::new(&self.global(),
- &self.device.get(),
- DOMString::from(service.uuid),
- service.is_primary,
- service.instance_id.clone());
- service_map.insert(service.instance_id, MutHeap::new(&bt_service));
+ let bt_service = device.get_or_create_service(&service, &self);
promise.resolve_native(promise_cx, &bt_service);
},
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservices
@@ -231,22 +220,8 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
// Step 7.
BluetoothResponse::GetPrimaryServices(services_vec) => {
let mut services = vec!();
- let context = self.device.get().get_context();
- let mut service_map = context.get_service_map().borrow_mut();
for service in services_vec {
- let bt_service = match service_map.get(&service.instance_id) {
- Some(existing_service) => existing_service.get(),
- None => {
- BluetoothRemoteGATTService::new(&self.global(),
- &self.device.get(),
- DOMString::from(service.uuid),
- service.is_primary,
- service.instance_id.clone())
- },
- };
- if !service_map.contains_key(&service.instance_id) {
- service_map.insert(service.instance_id, MutHeap::new(&bt_service));
- }
+ let bt_service = device.get_or_create_service(&service, &self);
services.push(bt_service);
}
promise.resolve_native(promise_cx, &services);