OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/bluetooth/BluetoothAttributeInstanceMap.h" | 5 #include "modules/bluetooth/BluetoothAttributeInstanceMap.h" |
6 | 6 |
7 #include "modules/bluetooth/BluetoothDevice.h" | 7 #include "modules/bluetooth/BluetoothDevice.h" |
8 #include "modules/bluetooth/BluetoothRemoteGATTService.h" | 8 #include "modules/bluetooth/BluetoothRemoteGATTService.h" |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 return characteristic; | 57 return characteristic; |
58 } | 58 } |
59 | 59 |
60 bool BluetoothAttributeInstanceMap::containsCharacteristic( | 60 bool BluetoothAttributeInstanceMap::containsCharacteristic( |
61 const String& characteristicInstanceId) { | 61 const String& characteristicInstanceId) { |
62 return m_characteristicIdToObject.contains(characteristicInstanceId); | 62 return m_characteristicIdToObject.contains(characteristicInstanceId); |
63 } | 63 } |
64 | 64 |
| 65 BluetoothRemoteGATTDescriptor* |
| 66 BluetoothAttributeInstanceMap::getOrCreateBluetoothRemoteGATTDescriptor( |
| 67 mojom::blink::WebBluetoothRemoteGATTDescriptorPtr descriptor, |
| 68 BluetoothRemoteGATTCharacteristic* characteristic) { |
| 69 String instanceId = descriptor->instance_id; |
| 70 BluetoothRemoteGATTDescriptor* result = |
| 71 m_descriptorIdToObject.get(instanceId); |
| 72 |
| 73 if (result) |
| 74 return result; |
| 75 |
| 76 result = |
| 77 new BluetoothRemoteGATTDescriptor(std::move(descriptor), characteristic); |
| 78 m_descriptorIdToObject.add(instanceId, result); |
| 79 return result; |
| 80 } |
| 81 |
| 82 bool BluetoothAttributeInstanceMap::containsDescriptor( |
| 83 const String& descriptorInstanceId) { |
| 84 return m_descriptorIdToObject.contains(descriptorInstanceId); |
| 85 } |
| 86 |
65 void BluetoothAttributeInstanceMap::Clear() { | 87 void BluetoothAttributeInstanceMap::Clear() { |
66 m_serviceIdToObject.clear(); | 88 m_serviceIdToObject.clear(); |
67 m_characteristicIdToObject.clear(); | 89 m_characteristicIdToObject.clear(); |
| 90 m_descriptorIdToObject.clear(); |
68 } | 91 } |
69 | 92 |
70 DEFINE_TRACE(BluetoothAttributeInstanceMap) { | 93 DEFINE_TRACE(BluetoothAttributeInstanceMap) { |
71 visitor->trace(m_device); | 94 visitor->trace(m_device); |
72 visitor->trace(m_serviceIdToObject); | 95 visitor->trace(m_serviceIdToObject); |
73 visitor->trace(m_characteristicIdToObject); | 96 visitor->trace(m_characteristicIdToObject); |
| 97 visitor->trace(m_descriptorIdToObject); |
74 } | 98 } |
75 | 99 |
76 } // namespace blink | 100 } // namespace blink |
OLD | NEW |