| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return getPrimaryServicesImpl(scriptState, mojom::blink::WebBluetoothGATTQue
ryQuantity::MULTIPLE, serviceUUID); | 139 return getPrimaryServicesImpl(scriptState, mojom::blink::WebBluetoothGATTQue
ryQuantity::MULTIPLE, serviceUUID); |
| 140 } | 140 } |
| 141 | 141 |
| 142 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServices(ScriptState* scriptS
tate, ExceptionState&) | 142 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServices(ScriptState* scriptS
tate, ExceptionState&) |
| 143 { | 143 { |
| 144 return getPrimaryServicesImpl(scriptState, mojom::blink::WebBluetoothGATTQue
ryQuantity::MULTIPLE); | 144 return getPrimaryServicesImpl(scriptState, mojom::blink::WebBluetoothGATTQue
ryQuantity::MULTIPLE); |
| 145 } | 145 } |
| 146 | 146 |
| 147 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServicesImpl(ScriptState* scr
iptState, mojom::blink::WebBluetoothGATTQueryQuantity quantity, String servicesU
UID) | 147 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServicesImpl(ScriptState* scr
iptState, mojom::blink::WebBluetoothGATTQueryQuantity quantity, String servicesU
UID) |
| 148 { | 148 { |
| 149 if (!connected()) { |
| 150 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NetworkError, "yay")); |
| 151 } |
| 149 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 152 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 150 ScriptPromise promise = resolver->promise(); | 153 ScriptPromise promise = resolver->promise(); |
| 151 | 154 |
| 152 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 155 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
| 153 webbluetooth->getPrimaryServices(device()->id(), static_cast<int32_t>(quanti
ty), servicesUUID, new GetPrimaryServicesCallback(device(), quantity, resolver))
; | 156 webbluetooth->getPrimaryServices(device()->id(), static_cast<int32_t>(quanti
ty), servicesUUID, new GetPrimaryServicesCallback(device(), quantity, resolver))
; |
| 154 | 157 |
| 155 return promise; | 158 return promise; |
| 156 } | 159 } |
| 157 | 160 |
| 158 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |