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

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

Issue 1152393002: bluetooth: Blink side implementation of getPrimaryService (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-get-primary-service-interface
Patch Set: Add BluetoothGATTService to webexposed layout test 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/BluetoothGATTRemoteServer.cpp
diff --git a/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp b/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp
index 994af71eaa41d426dd3fa97196b48d167569e1b6..b2a55a09286a3cc57ac09cd736205fe1a48c0fe5 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,17 @@ void BluetoothGATTRemoteServer::dispose(WebBluetoothGATTRemoteServer* webGATTRaw
delete webGATTRaw;
}
+ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptState, String serviceUUID)
+{
+ // TODO(ortuno): BluetoothUUID.getService(serviceUUID)
+ // https://crbug.com/491441
+ WebBluetooth* webbluetooth = Platform::current()->bluetooth();
+
+ 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
« no previous file with comments | « Source/modules/bluetooth/BluetoothGATTRemoteServer.h ('k') | Source/modules/bluetooth/BluetoothGATTRemoteServer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698