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

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

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: rebase to master 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..55eaaa01ba564cfc3e1beb1cb8e60aa39df15f3f 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,44 @@ 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)
+ return descriptor;
+
+ if (!webDescriptor)
ortuno 2016/12/08 05:42:52 Just DCHECK. I don't think this will ever be calle
dougt 2016/12/08 08:35:59 Done.
+ return nullptr;
+
+ descriptor = new BluetoothRemoteGATTDescriptor(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