Chromium Code Reviews| 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 |