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/BluetoothRemoteGATTServer.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // disconnected so we reject. | 132 // disconnected so we reject. |
133 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) { | 133 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) { |
134 m_resolver->reject( | 134 m_resolver->reject( |
135 DOMException::create(NetworkError, kGATTServerDisconnected)); | 135 DOMException::create(NetworkError, kGATTServerDisconnected)); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { | 139 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { |
140 DCHECK_EQ(1u, webServices.size()); | 140 DCHECK_EQ(1u, webServices.size()); |
141 m_resolver->resolve(m_device->getOrCreateBluetoothRemoteGATTService( | 141 m_resolver->resolve(m_device->getOrCreateBluetoothRemoteGATTService( |
142 wrapUnique(webServices[0]))); | 142 WTF::wrapUnique(webServices[0]))); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 HeapVector<Member<BluetoothRemoteGATTService>> services; | 146 HeapVector<Member<BluetoothRemoteGATTService>> services; |
147 services.reserveInitialCapacity(webServices.size()); | 147 services.reserveInitialCapacity(webServices.size()); |
148 for (WebBluetoothRemoteGATTService* webService : webServices) { | 148 for (WebBluetoothRemoteGATTService* webService : webServices) { |
149 services.append(m_device->getOrCreateBluetoothRemoteGATTService( | 149 services.append(m_device->getOrCreateBluetoothRemoteGATTService( |
150 wrapUnique(webService))); | 150 WTF::wrapUnique(webService))); |
151 } | 151 } |
152 m_resolver->resolve(services); | 152 m_resolver->resolve(services); |
153 } | 153 } |
154 | 154 |
155 void onError( | 155 void onError( |
156 int32_t | 156 int32_t |
157 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) | 157 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) |
158 override { | 158 override { |
159 if (!m_resolver->getExecutionContext() || | 159 if (!m_resolver->getExecutionContext() || |
160 m_resolver->getExecutionContext()->isContextDestroyed()) | 160 m_resolver->getExecutionContext()->isContextDestroyed()) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 WebBluetooth* webbluetooth = | 224 WebBluetooth* webbluetooth = |
225 BluetoothSupplement::fromScriptState(scriptState); | 225 BluetoothSupplement::fromScriptState(scriptState); |
226 webbluetooth->getPrimaryServices( | 226 webbluetooth->getPrimaryServices( |
227 device()->id(), static_cast<int32_t>(quantity), servicesUUID, | 227 device()->id(), static_cast<int32_t>(quantity), servicesUUID, |
228 new GetPrimaryServicesCallback(device(), quantity, resolver)); | 228 new GetPrimaryServicesCallback(device(), quantity, resolver)); |
229 | 229 |
230 return promise; | 230 return promise; |
231 } | 231 } |
232 | 232 |
233 } // namespace blink | 233 } // namespace blink |
OLD | NEW |