Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1228)

Unified Diff: Source/modules/bluetooth/BluetoothGATTService.cpp

Issue 1146163005: bluetooth: Blink-side implementation of getCharacteristic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-characteristic-interface
Patch Set: getCharacteristic Blink-Side Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/bluetooth/BluetoothGATTService.cpp
diff --git a/Source/modules/bluetooth/BluetoothGATTService.cpp b/Source/modules/bluetooth/BluetoothGATTService.cpp
index 620b1bce5d390a9052d02a5dfc1e901028dadfa5..d8be80a21a4883d607027e21ceecc7ad86343071 100644
--- a/Source/modules/bluetooth/BluetoothGATTService.cpp
+++ b/Source/modules/bluetooth/BluetoothGATTService.cpp
@@ -5,7 +5,15 @@
#include "config.h"
#include "modules/bluetooth/BluetoothGATTService.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/BluetoothGATTCharacteristic.h"
+#include "public/platform/Platform.h"
+#include "public/platform/modules/bluetooth/WebBluetooth.h"
#include "wtf/OwnPtr.h"
namespace blink {
@@ -29,4 +37,16 @@ void BluetoothGATTService::dispose(WebBluetoothGATTService* webService)
delete webService;
}
+ScriptPromise BluetoothGATTService::getCharacteristic(ScriptState* scriptState,
+ String characteristicUUID)
+{
+ WebBluetooth* webbluetooth = Platform::current()->bluetooth();
+ if (!webbluetooth)
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ webbluetooth->getCharacteristic(m_webService.serviceInstanceID, characteristicUUID, new CallbackPromiseAdapter<BluetoothGATTCharacteristic, BluetoothError>(resolver));
+ return promise;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698