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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/bluetooth/BluetoothDiscovery.h" 6 #include "modules/bluetooth/BluetoothDiscovery.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "modules/bluetooth/BluetoothError.h"
14 #include "modules/bluetooth/testing/BluetoothMock.h"
15 #include "public/platform/Platform.h"
11 16
12 namespace blink { 17 namespace blink {
13 18
14 ScriptPromise BluetoothDiscovery::requestDevice(ScriptState* scriptState) 19 ScriptPromise BluetoothDiscovery::requestDevice(ScriptState* scriptState)
15 { 20 {
16 // FIXME: Implement requestDevice: http://crbug.com/420284. 21 WebBluetooth* webbluetooth = m_bluetoothMock ? m_bluetoothMock : Platform::c urrent()->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
17 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError)); 22 if (!webbluetooth)
23 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
24
25 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
26 ScriptPromise promise = resolver->promise();
27 webbluetooth->requestDevice(new CallbackPromiseAdapter<void, BluetoothError> (resolver));
28 return promise;
29 }
30
31 void BluetoothDiscovery::resetBluetoothMockForTesting()
32 {
33 m_bluetoothMock = new BluetoothMock();
34 }
35
36 void BluetoothDiscovery::trace(Visitor* visitor)
37 {
38 visitor->trace(m_bluetoothMock);
18 } 39 }
19 40
20 } // namespace blink 41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698