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

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

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: Rebase Created 4 years 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 f58be91213ca31276baaaa8b454be0eae341644e..4a32e2bcec730243ecb1f328cf489c88d34c1f24 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp
@@ -7,6 +7,8 @@
#include "modules/bluetooth/BluetoothDevice.h"
#include "modules/bluetooth/BluetoothRemoteGATTService.h"
#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristicInit.h"
+#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTDescriptorInit.h"
+
#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h"
#include <memory>
#include <utility>
@@ -63,15 +65,40 @@ bool BluetoothAttributeInstanceMap::containsCharacteristic(
return m_characteristicIdToObject.contains(characteristicInstanceId);
}
+BluetoothRemoteGATTDescriptor*
+BluetoothAttributeInstanceMap::getOrCreateBluetoothRemoteGATTDescriptor(
+ std::unique_ptr<WebBluetoothRemoteGATTDescriptorInit> webDescriptor,
+ BluetoothRemoteGATTCharacteristic* characteristic) {
+ String descriptorInstanceId = webDescriptor->descriptorInstanceID;
+
+ BluetoothRemoteGATTDescriptor* descriptor =
+ m_descriptorIdToObject.get(descriptorInstanceId);
+
+ if (!descriptor) {
+ descriptor = BluetoothRemoteGATTDescriptor::create(std::move(webDescriptor),
+ characteristic);
+ m_descriptorIdToObject.add(descriptorInstanceId, descriptor);
+ }
+
+ return descriptor;
+}
+
+bool BluetoothAttributeInstanceMap::containsDescriptor(
+ const String& descriptorInstanceId) {
+ return m_descriptorIdToObject.contains(descriptorInstanceId);
+}
+
void BluetoothAttributeInstanceMap::Clear() {
m_serviceIdToObject.clear();
m_characteristicIdToObject.clear();
+ m_descriptorIdToObject.clear();
}
DEFINE_TRACE(BluetoothAttributeInstanceMap) {
visitor->trace(m_device);
visitor->trace(m_serviceIdToObject);
visitor->trace(m_characteristicIdToObject);
+ visitor->trace(m_descriptorIdToObject);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698