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

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

Issue 650613005: bluetooth: Initial WebBluetooth & WebBluetoothError. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Abandoned initial approach implementing BluetoothMock in Blink. Created 6 years, 2 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/BluetoothDiscovery.cpp
diff --git a/Source/modules/bluetooth/BluetoothDiscovery.cpp b/Source/modules/bluetooth/BluetoothDiscovery.cpp
index 7f982a751992c7625dd7c2f2e44fac41507404ca..f2ac3dfc96c74bab0a8371c5b58608ad7b0e925d 100644
--- a/Source/modules/bluetooth/BluetoothDiscovery.cpp
+++ b/Source/modules/bluetooth/BluetoothDiscovery.cpp
@@ -5,16 +5,37 @@
#include "config.h"
#include "modules/bluetooth/BluetoothDiscovery.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/testing/BluetoothMock.h"
+#include "public/platform/Platform.h"
namespace blink {
ScriptPromise BluetoothDiscovery::requestDevice(ScriptState* scriptState)
{
- // FIXME: Implement requestDevice: http://crbug.com/420284.
- return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
+ WebBluetooth* webbluetooth = m_bluetoothMock ? m_bluetoothMock : Platform::current()->bluetooth();
haraken 2014/10/18 11:25:56 Help me understand: What is this doing? Who sets t
scheib 2014/10/19 03:54:21 The platform should provide the WebBluetooth inter
+ if (!webbluetooth)
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
+
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ webbluetooth->requestDevice(new CallbackPromiseAdapter<void, BluetoothError>(resolver));
+ return promise;
+}
+
+void BluetoothDiscovery::resetBluetoothMockForTesting()
+{
+ m_bluetoothMock = new BluetoothMock();
+}
+
+void BluetoothDiscovery::trace(Visitor* visitor)
+{
+ visitor->trace(m_bluetoothMock);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698