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

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: Fixed 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..b4215b589e8d4c966888c0fe39407117b01c8197 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,16 @@ void BluetoothGATTRemoteServer::dispose(WebBluetoothGATTRemoteServer* webGATTRaw
delete webGATTRaw;
}
+ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptState,
+ String serviceUUID)
+{
scheib 2015/05/29 00:17:32 TODO: BluetoothUUID.getService(serviceUUID) crbug.
ortuno 2015/06/01 21:21:34 Done.
+ 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->getPrimaryService(m_webGATT.deviceInstanceID, serviceUUID, new CallbackPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver));
+ return promise;
+}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698