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

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

Issue 1060593004: bluetooth: connectGATT and receive WebBluetoothGATTRemoteServer from embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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/BluetoothDevice.cpp
diff --git a/Source/modules/bluetooth/BluetoothDevice.cpp b/Source/modules/bluetooth/BluetoothDevice.cpp
index e80113dd7315222be8502d53f324e5db2fee847d..0e8fba200326ab3b2619856050341a314e32c9bd 100644
--- a/Source/modules/bluetooth/BluetoothDevice.cpp
+++ b/Source/modules/bluetooth/BluetoothDevice.cpp
@@ -5,6 +5,15 @@
#include "config.h"
#include "modules/bluetooth/BluetoothDevice.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/BluetoothGATTRemoteServer.h"
+#include "public/platform/Platform.h"
+#include "public/platform/modules/bluetooth/WebBluetooth.h"
#include "wtf/OwnPtr.h"
namespace blink {
@@ -86,5 +95,15 @@ Vector<String> BluetoothDevice::uuids(bool& isNull)
return uuids;
}
-} // namespace blink
+ScriptPromise BluetoothDevice::connectGATT(ScriptState* scriptState)
+{
+ WebBluetooth* webbluetooth = Platform::current()->bluetooth();
+ if (!webbluetooth)
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ webbluetooth->connectGATT(instanceID(), new CallbackPromiseAdapter<BluetoothGATTRemoteServer, BluetoothError>(resolver));
+ return promise;
+}
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698