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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothFakeBluetooth.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/BluetoothFakeBluetooth.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothFakeBluetooth.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothFakeBluetooth.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d0c50e42020ed8207507d493c0383483af383ae0
--- /dev/null
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothFakeBluetooth.cpp
@@ -0,0 +1,46 @@
+// 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/BluetoothFakeBluetooth.h"
+
+#include "modules/bluetooth/Bluetooth.h"
+#include "modules/bluetooth/FakeBluetooth.h"
+
+namespace blink {
+
+BluetoothFakeBluetooth& BluetoothFakeBluetooth::from(Bluetooth& bluetooth) {
+ BluetoothFakeBluetooth* supplement = static_cast<BluetoothFakeBluetooth*>(
+ Supplement<Bluetooth>::from(bluetooth, supplementName()));
+
+ if (!supplement) {
+ supplement = new BluetoothFakeBluetooth(bluetooth);
+ provideTo(bluetooth, supplementName(), supplement);
+ }
+ return *supplement;
+}
+
+FakeBluetooth* BluetoothFakeBluetooth::test(Bluetooth& bluetooth) {
+ return BluetoothFakeBluetooth::from(bluetooth).test();
+}
+
+FakeBluetooth* BluetoothFakeBluetooth::test() {
+ if (!m_test)
+ m_test = FakeBluetooth::create();
+ return m_test.get();
+}
+
+DEFINE_TRACE(BluetoothFakeBluetooth) {
+ visitor->trace(m_test);
+ Supplement<Bluetooth>::trace(visitor);
+}
+
+BluetoothFakeBluetooth::BluetoothFakeBluetooth(Bluetooth& bluetooth)
+ : Supplement<Bluetooth>(bluetooth) {
+}
+
+const char* BluetoothFakeBluetooth::supplementName() {
+ return "BluetoothFakeBluetooth";
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698