| Index: third_party/WebKit/Source/modules/bluetooth/FakeLEPeripheral.cpp
|
| diff --git a/third_party/WebKit/Source/modules/bluetooth/FakeLEPeripheral.cpp b/third_party/WebKit/Source/modules/bluetooth/FakeLEPeripheral.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..322710c1d2949a0549cc820e9e28d9c55caa309b
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/bluetooth/FakeLEPeripheral.cpp
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "modules/bluetooth/FakeLEPeripheral.h"
|
| +#include "modules/bluetooth/FakeLEPeripheral.h"
|
| +
|
| +#include "bindings/core/v8/ScriptPromise.h"
|
| +#include "bindings/core/v8/ScriptPromiseResolver.h"
|
| +#include "core/dom/DOMException.h"
|
| +#include "modules/bluetooth/FakeRemoteGATTService.h"
|
| +
|
| +namespace blink {
|
| +
|
| +FakeLEPeripheral::FakeLEPeripheral() { }
|
| +
|
| +ScriptPromise FakeLEPeripheral::simulateGATTConnection(ScriptState* scriptState, String connectionResult) {
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve();
|
| + return promise;
|
| +}
|
| +
|
| +ScriptPromise FakeLEPeripheral::simulateGATTDiscoveryComplete(ScriptState* scriptState) {
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve();
|
| + return promise;
|
| +}
|
| +
|
| +ScriptPromise FakeLEPeripheral::simulateGATTDiscoveryError(ScriptState* scriptState) {
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve();
|
| + return promise;
|
| +}
|
| +
|
| +ScriptPromise FakeLEPeripheral::addFakeService(ScriptState* scriptState, const FakeRemoteGATTServiceOptions& options) {
|
| + FakeRemoteGATTService* service = FakeRemoteGATTService::create();
|
| + m_services.insert(service);
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve(service);
|
| + return promise;
|
| +}
|
| +
|
| +ScriptPromise FakeLEPeripheral::removeFakeService(ScriptState* scriptState, FakeRemoteGATTService* service) {
|
| + if (m_services.contains(service)) {
|
| + m_services.erase(service);
|
| + }
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + resolver->resolve();
|
| + return promise;
|
| +}
|
| +
|
| +DEFINE_TRACE(FakeLEPeripheral) {
|
| + visitor->trace(m_services);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|