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

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

Issue 2474863004: bluetooth: Add characteristics to the device's attribute instance map (Closed)
Patch Set: clean up Created 4 years, 1 month 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/BluetoothAttributeInstanceMap.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp
index 8fef103f1ec53ec516ad048d1226023dc98134da..cbeab082164b8bd3b77444bbfc3153bb30b704c7 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp
@@ -6,6 +6,7 @@
#include "modules/bluetooth/BluetoothDevice.h"
#include "modules/bluetooth/BluetoothRemoteGATTService.h"
+#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristicInit.h"
#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h"
#include <memory>
#include <utility>
@@ -38,6 +39,25 @@ bool BluetoothAttributeInstanceMap::containsService(
return m_serviceIdToObject.contains(serviceInstanceId);
}
+BluetoothRemoteGATTCharacteristic*
+BluetoothAttributeInstanceMap::getOrCreateBluetoothRemoteGATTCharacteristic(
+ ExecutionContext* context,
+ std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> webCharacteristic,
+ BluetoothRemoteGATTService* service) {
+ String characteristicInstanceId = webCharacteristic->characteristicInstanceID;
+
+ BluetoothRemoteGATTCharacteristic* characteristic =
+ m_characteristicIdToObject.get(characteristicInstanceId);
+
+ if (!characteristic) {
+ characteristic = BluetoothRemoteGATTCharacteristic::create(
+ context, std::move(webCharacteristic), service);
+ m_characteristicIdToObject.add(characteristicInstanceId, characteristic);
+ }
+
+ return characteristic;
+}
+
void BluetoothAttributeInstanceMap::Clear() {
m_serviceIdToObject.clear();
}
@@ -45,6 +65,7 @@ void BluetoothAttributeInstanceMap::Clear() {
DEFINE_TRACE(BluetoothAttributeInstanceMap) {
visitor->trace(m_device);
visitor->trace(m_serviceIdToObject);
+ visitor->trace(m_characteristicIdToObject);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698