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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp

Issue 2716263002: DO NOT SUBMIT. Renderer side of Bluetooth Test API in blink C++ (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp b/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..313c70c69ce5530ddeb040587c9b9949da314095
--- /dev/null
+++ b/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp
@@ -0,0 +1,60 @@
+// 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/FakeLECentralManager.h"
+
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
+#include "modules/bluetooth/FakeLEPeripheral.h"
+#include "modules/bluetooth/FakeCentralOptions.h"
+
+namespace blink {
+
+FakeLECentralManager::FakeLECentralManager() {
+}
+
+ScriptPromise FakeLECentralManager::simulateAdvertisementReceived(ScriptState* scriptState, const ScanResult&) {
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve(FakeLEPeripheral::create());
+ return promise;
+}
+
+ScriptPromise FakeLECentralManager::addConnectedLEPeripheral(ScriptState* scriptState, const FakeLEPeripheralOptions&) {
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve(FakeLEPeripheral::create());
+ return promise;
+}
+
+ScriptPromise FakeLECentralManager::setState(ScriptState* scriptState, String newState) {
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve();
+ return promise;
+}
+
+ScriptPromise FakeLECentralManager::getStartScanCalls(ScriptState* scriptState) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState, DOMException::create(NotSupportedError, "Not supported"));
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve(0);
+ return promise;
+}
+
+ScriptPromise FakeLECentralManager::getStopScanCalls(ScriptState* scriptState) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState, DOMException::create(NotSupportedError, "Not supported"));
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve(1);
+ return promise;
+}
+
+DEFINE_TRACE(FakeLECentralManager) {
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698