OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/bluetooth/FakeLEPeripheral.h" |
| 6 #include "modules/bluetooth/FakeLEPeripheral.h" |
| 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMException.h" |
| 11 #include "modules/bluetooth/FakeRemoteGATTService.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 FakeLEPeripheral::FakeLEPeripheral() { } |
| 16 |
| 17 ScriptPromise FakeLEPeripheral::simulateGATTConnection(ScriptState* scriptState,
String connectionResult) { |
| 18 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 19 ScriptPromise promise = resolver->promise(); |
| 20 resolver->resolve(); |
| 21 return promise; |
| 22 } |
| 23 |
| 24 ScriptPromise FakeLEPeripheral::simulateGATTDiscoveryComplete(ScriptState* scrip
tState) { |
| 25 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 26 ScriptPromise promise = resolver->promise(); |
| 27 resolver->resolve(); |
| 28 return promise; |
| 29 } |
| 30 |
| 31 ScriptPromise FakeLEPeripheral::simulateGATTDiscoveryError(ScriptState* scriptSt
ate) { |
| 32 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 33 ScriptPromise promise = resolver->promise(); |
| 34 resolver->resolve(); |
| 35 return promise; |
| 36 } |
| 37 |
| 38 ScriptPromise FakeLEPeripheral::addFakeService(ScriptState* scriptState, const F
akeRemoteGATTServiceOptions& options) { |
| 39 FakeRemoteGATTService* service = FakeRemoteGATTService::create(); |
| 40 m_services.insert(service); |
| 41 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 42 ScriptPromise promise = resolver->promise(); |
| 43 resolver->resolve(service); |
| 44 return promise; |
| 45 } |
| 46 |
| 47 ScriptPromise FakeLEPeripheral::removeFakeService(ScriptState* scriptState, Fake
RemoteGATTService* service) { |
| 48 if (m_services.contains(service)) { |
| 49 m_services.erase(service); |
| 50 } |
| 51 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 52 ScriptPromise promise = resolver->promise(); |
| 53 resolver->resolve(); |
| 54 return promise; |
| 55 } |
| 56 |
| 57 DEFINE_TRACE(FakeLEPeripheral) { |
| 58 visitor->trace(m_services); |
| 59 } |
| 60 |
| 61 } // namespace blink |
OLD | NEW |