OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/bluetooth/BluetoothRemoteGATTService.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTService.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 resolver->getExecutionContext(), | 77 resolver->getExecutionContext(), |
78 characteristics.value()[0]->instance_id, serviceInstanceId, | 78 characteristics.value()[0]->instance_id, serviceInstanceId, |
79 characteristics.value()[0]->uuid, | 79 characteristics.value()[0]->uuid, |
80 characteristics.value()[0]->properties, this)); | 80 characteristics.value()[0]->properties, this)); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> gattCharacteristics; | 84 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> gattCharacteristics; |
85 gattCharacteristics.reserveInitialCapacity(characteristics->size()); | 85 gattCharacteristics.reserveInitialCapacity(characteristics->size()); |
86 for (const auto& characteristic : characteristics.value()) { | 86 for (const auto& characteristic : characteristics.value()) { |
87 gattCharacteristics.append(device()->getOrCreateRemoteGATTCharacteristic( | 87 gattCharacteristics.push_back( |
88 resolver->getExecutionContext(), characteristic->instance_id, | 88 device()->getOrCreateRemoteGATTCharacteristic( |
89 serviceInstanceId, characteristic->uuid, characteristic->properties, | 89 resolver->getExecutionContext(), characteristic->instance_id, |
90 this)); | 90 serviceInstanceId, characteristic->uuid, |
| 91 characteristic->properties, this)); |
91 } | 92 } |
92 resolver->resolve(gattCharacteristics); | 93 resolver->resolve(gattCharacteristics); |
93 } else { | 94 } else { |
94 resolver->reject(BluetoothError::take(resolver, result)); | 95 resolver->reject(BluetoothError::take(resolver, result)); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 ScriptPromise BluetoothRemoteGATTService::getCharacteristic( | 99 ScriptPromise BluetoothRemoteGATTService::getCharacteristic( |
99 ScriptState* scriptState, | 100 ScriptState* scriptState, |
100 const StringOrUnsignedLong& characteristic, | 101 const StringOrUnsignedLong& characteristic, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 m_serviceInstanceId, quantity, uuid, | 160 m_serviceInstanceId, quantity, uuid, |
160 convertToBaseCallback( | 161 convertToBaseCallback( |
161 WTF::bind(&BluetoothRemoteGATTService::GetCharacteristicsCallback, | 162 WTF::bind(&BluetoothRemoteGATTService::GetCharacteristicsCallback, |
162 wrapPersistent(this), m_serviceInstanceId, quantity, | 163 wrapPersistent(this), m_serviceInstanceId, quantity, |
163 wrapPersistent(resolver)))); | 164 wrapPersistent(resolver)))); |
164 | 165 |
165 return promise; | 166 return promise; |
166 } | 167 } |
167 | 168 |
168 } // namespace blink | 169 } // namespace blink |
OLD | NEW |