OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/bluetooth/BluetoothRemoteGATTServer.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 , m_resolver(resolver) {} | 41 , m_resolver(resolver) {} |
42 | 42 |
43 void onSuccess() override | 43 void onSuccess() override |
44 { | 44 { |
45 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 45 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
46 return; | 46 return; |
47 m_device->gatt()->setConnected(true); | 47 m_device->gatt()->setConnected(true); |
48 m_resolver->resolve(m_device->gatt()); | 48 m_resolver->resolve(m_device->gatt()); |
49 } | 49 } |
50 | 50 |
51 void onError(const WebBluetoothError& e) override | 51 void onError(const mojom::WebBluetoothError& e) override |
52 { | 52 { |
53 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 53 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
54 return; | 54 return; |
55 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 55 m_resolver->reject(BluetoothError::take(m_resolver, e)); |
56 } | 56 } |
57 private: | 57 private: |
58 Persistent<BluetoothDevice> m_device; | 58 Persistent<BluetoothDevice> m_device; |
59 Persistent<ScriptPromiseResolver> m_resolver; | 59 Persistent<ScriptPromiseResolver> m_resolver; |
60 }; | 60 }; |
61 | 61 |
(...skipping 25 matching lines...) Expand all Loading... |
87 return exceptionState.reject(scriptState); | 87 return exceptionState.reject(scriptState); |
88 | 88 |
89 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 89 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
90 ScriptPromise promise = resolver->promise(); | 90 ScriptPromise promise = resolver->promise(); |
91 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro
miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver)); | 91 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro
miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver)); |
92 | 92 |
93 return promise; | 93 return promise; |
94 } | 94 } |
95 | 95 |
96 } // namespace blink | 96 } // namespace blink |
OLD | NEW |