OLD | NEW |
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/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
13 #include "modules/bluetooth/BluetoothDevice.h" | 13 #include "modules/bluetooth/BluetoothDevice.h" |
14 #include "modules/bluetooth/BluetoothError.h" | 14 #include "modules/bluetooth/BluetoothError.h" |
15 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
16 #include "public/platform/WebBluetooth.h" | 16 #include "public/platform/WebBluetooth.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 ScriptPromise BluetoothDiscovery::requestDevice(ScriptState* scriptState) | 20 ScriptPromise BluetoothDiscovery::requestDevice(ScriptState* scriptState) |
21 { | 21 { |
22 WebBluetooth* webbluetooth = Platform::current()->bluetooth(); | 22 WebBluetooth* webbluetooth = Platform::current()->bluetooth(); |
23 if (!webbluetooth) | 23 if (!webbluetooth) |
24 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); | 24 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); |
25 | 25 |
26 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 26 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
27 ScriptPromise promise = resolver->promise(); | 27 ScriptPromise promise = resolver->promise(); |
28 webbluetooth->requestDevice(new CallbackPromiseAdapter<BluetoothDevice, Blue
toothError>(resolver)); | 28 webbluetooth->requestDevice(new CallbackPromiseAdapter<BluetoothDevice, Blue
toothError>(resolver)); |
29 return promise; | 29 return promise; |
30 } | 30 } |
31 | 31 |
32 } // namespace blink | 32 } // namespace blink |
OLD | NEW |