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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 m_resolver->reject( | 72 m_resolver->reject( |
73 DOMException::create(NetworkError, kGATTServerDisconnected)); | 73 DOMException::create(NetworkError, kGATTServerDisconnected)); |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { | 77 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { |
78 DCHECK_EQ(1u, webCharacteristics.size()); | 78 DCHECK_EQ(1u, webCharacteristics.size()); |
79 m_resolver->resolve( | 79 m_resolver->resolve( |
80 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic( | 80 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic( |
81 m_resolver->getExecutionContext(), | 81 m_resolver->getExecutionContext(), |
82 wrapUnique(webCharacteristics[0]), m_service)); | 82 WTF::wrapUnique(webCharacteristics[0]), m_service)); |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> characteristics; | 86 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> characteristics; |
87 characteristics.reserveInitialCapacity(webCharacteristics.size()); | 87 characteristics.reserveInitialCapacity(webCharacteristics.size()); |
88 for (WebBluetoothRemoteGATTCharacteristicInit* webCharacteristic : | 88 for (WebBluetoothRemoteGATTCharacteristicInit* webCharacteristic : |
89 webCharacteristics) { | 89 webCharacteristics) { |
90 characteristics.append( | 90 characteristics.append( |
91 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic( | 91 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic( |
92 m_resolver->getExecutionContext(), wrapUnique(webCharacteristic), | 92 m_resolver->getExecutionContext(), |
93 m_service)); | 93 WTF::wrapUnique(webCharacteristic), m_service)); |
94 } | 94 } |
95 m_resolver->resolve(characteristics); | 95 m_resolver->resolve(characteristics); |
96 } | 96 } |
97 | 97 |
98 void onError( | 98 void onError( |
99 int32_t | 99 int32_t |
100 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) | 100 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) |
101 override { | 101 override { |
102 if (!m_resolver->getExecutionContext() || | 102 if (!m_resolver->getExecutionContext() || |
103 m_resolver->getExecutionContext()->isContextDestroyed()) | 103 m_resolver->getExecutionContext()->isContextDestroyed()) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 BluetoothSupplement::fromScriptState(scriptState); | 178 BluetoothSupplement::fromScriptState(scriptState); |
179 webbluetooth->getCharacteristics( | 179 webbluetooth->getCharacteristics( |
180 m_webService->serviceInstanceID, static_cast<int32_t>(quantity), | 180 m_webService->serviceInstanceID, static_cast<int32_t>(quantity), |
181 characteristicsUUID, | 181 characteristicsUUID, |
182 new GetCharacteristicsCallback(this, quantity, resolver)); | 182 new GetCharacteristicsCallback(this, quantity, resolver)); |
183 | 183 |
184 return promise; | 184 return promise; |
185 } | 185 } |
186 | 186 |
187 } // namespace blink | 187 } // namespace blink |
OLD | NEW |