Chromium Code Reviews| Index: Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp |
| diff --git a/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp b/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp |
| index 994af71eaa41d426dd3fa97196b48d167569e1b6..c062d4d5039defc5695cea2ca4b354141d505237 100644 |
| --- a/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp |
| +++ b/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp |
| @@ -5,7 +5,15 @@ |
| #include "config.h" |
| #include "modules/bluetooth/BluetoothGATTRemoteServer.h" |
| -#include "public/platform/modules/bluetooth/WebBluetoothGATTRemoteServer.h" |
| +#include "bindings/core/v8/CallbackPromiseAdapter.h" |
| +#include "bindings/core/v8/ScriptPromise.h" |
| +#include "bindings/core/v8/ScriptPromiseResolver.h" |
| +#include "core/dom/DOMException.h" |
| +#include "core/dom/ExceptionCode.h" |
| +#include "modules/bluetooth/BluetoothError.h" |
| +#include "modules/bluetooth/BluetoothGATTService.h" |
| +#include "public/platform/Platform.h" |
| +#include "public/platform/modules/bluetooth/WebBluetooth.h" |
| #include "wtf/OwnPtr.h" |
| namespace blink { |
| @@ -26,5 +34,18 @@ void BluetoothGATTRemoteServer::dispose(WebBluetoothGATTRemoteServer* webGATTRaw |
| delete webGATTRaw; |
| } |
| +ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptState, |
| + String serviceUUID) |
|
Jeffrey Yasskin
2015/06/02 20:28:08
IIRC, Blink likes keeping arguments all on one lin
ortuno
2015/06/03 03:05:16
Done.
|
| +{ |
| + // TODO(ortuno): BluetoothUUID.getService(serviceUUID) |
| + // https://crbug.com/491441 |
| + WebBluetooth* webbluetooth = Platform::current()->bluetooth(); |
| + if (!webbluetooth) |
| + return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError)); |
|
Jeffrey Yasskin
2015/06/02 20:28:08
How would this happen? I'd assume that JS couldn't
ortuno
2015/06/03 03:05:16
Ah you're right. I shouldn't be copy pasting code.
|
| + RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
| + ScriptPromise promise = resolver->promise(); |
| + webbluetooth->getPrimaryService(m_webGATT.deviceInstanceID, serviceUUID, new CallbackPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver)); |
| + return promise; |
| +} |
| } // namespace blink |