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

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: Web Exposed test changed 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
« no previous file with comments | « Source/modules/bluetooth/BluetoothDevice.h ('k') | Source/modules/bluetooth/BluetoothDevice.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/bluetooth/BluetoothDevice.cpp
diff --git a/Source/modules/bluetooth/BluetoothDevice.cpp b/Source/modules/bluetooth/BluetoothDevice.cpp
index 0245ec3d5a9991557beb88117b8ab94e92e892ae..985319686ec0da11f2ea90cecba4e672edd2b63e 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 {
@@ -78,5 +87,15 @@ Vector<String> BluetoothDevice::uuids()
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
« no previous file with comments | « Source/modules/bluetooth/BluetoothDevice.h ('k') | Source/modules/bluetooth/BluetoothDevice.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698