| 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 #ifndef BluetoothAttributeInstanceMap_h | 5 #ifndef BluetoothAttributeInstanceMap_h |
| 6 #define BluetoothAttributeInstanceMap_h | 6 #define BluetoothAttributeInstanceMap_h |
| 7 | 7 |
| 8 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" | 8 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 9 #include "modules/bluetooth/BluetoothRemoteGATTDescriptor.h" |
| 9 #include "modules/bluetooth/BluetoothRemoteGATTService.h" | 10 #include "modules/bluetooth/BluetoothRemoteGATTService.h" |
| 10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 11 #include "platform/heap/Heap.h" | 12 #include "platform/heap/Heap.h" |
| 12 #include <memory> | 13 #include <memory> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class BluetoothDevice; | 17 class BluetoothDevice; |
| 17 class ExecutionContext; | 18 class ExecutionContext; |
| 18 | 19 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 BluetoothRemoteGATTCharacteristic* | 47 BluetoothRemoteGATTCharacteristic* |
| 47 getOrCreateBluetoothRemoteGATTCharacteristic( | 48 getOrCreateBluetoothRemoteGATTCharacteristic( |
| 48 ExecutionContext*, | 49 ExecutionContext*, |
| 49 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>, | 50 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>, |
| 50 BluetoothRemoteGATTService*); | 51 BluetoothRemoteGATTService*); |
| 51 | 52 |
| 52 // Returns true if a BluetoothRemoteGATTCharacteristic with | 53 // Returns true if a BluetoothRemoteGATTCharacteristic with |
| 53 // |characteristicInstanceId| is in the map. | 54 // |characteristicInstanceId| is in the map. |
| 54 bool containsCharacteristic(const String& characteristicInstanceId); | 55 bool containsCharacteristic(const String& characteristicInstanceId); |
| 55 | 56 |
| 57 // Constructs a new BluetoothRemoteGATTDescriptor object if there was no |
| 58 // descriptor with the same instance id and adds it to the map. |
| 59 // Otherwise returns the BluetoothRemoteGATTDescriptor object already in |
| 60 // the map. |
| 61 BluetoothRemoteGATTDescriptor* getOrCreateBluetoothRemoteGATTDescriptor( |
| 62 std::unique_ptr<WebBluetoothRemoteGATTDescriptorInit>, |
| 63 BluetoothRemoteGATTCharacteristic*); |
| 64 |
| 65 // Returns true if a BluetoothRemoteGATTDescriptor with |
| 66 // |descriptorInstanceId| is in the map. |
| 67 bool containsDescriptor(const String& descriptorInstanceId); |
| 68 |
| 56 // Removes all Attributes from the map. | 69 // Removes all Attributes from the map. |
| 57 // TODO(crbug.com/654950): Remove descriptors when implemented. | 70 // TODO(crbug.com/654950): Remove descriptors when implemented. |
| 58 void Clear(); | 71 void Clear(); |
| 59 | 72 |
| 60 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
| 61 | 74 |
| 62 private: | 75 private: |
| 63 // BluetoothDevice that owns this map. | 76 // BluetoothDevice that owns this map. |
| 64 Member<BluetoothDevice> m_device; | 77 Member<BluetoothDevice> m_device; |
| 65 // Map of service instance ids to objects. | 78 // Map of service instance ids to objects. |
| 66 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject; | 79 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject; |
| 67 // Map of characteristic instance ids to objects. | 80 // Map of characteristic instance ids to objects. |
| 68 HeapHashMap<String, Member<BluetoothRemoteGATTCharacteristic>> | 81 HeapHashMap<String, Member<BluetoothRemoteGATTCharacteristic>> |
| 69 m_characteristicIdToObject; | 82 m_characteristicIdToObject; |
| 83 // Map of descriptor instance ids to objects. |
| 84 HeapHashMap<String, Member<BluetoothRemoteGATTDescriptor>> |
| 85 m_descriptorIdToObject; |
| 70 }; | 86 }; |
| 71 | 87 |
| 72 } // namespace blink | 88 } // namespace blink |
| 73 | 89 |
| 74 #endif // BluetoothAttributeInstanceMap_h | 90 #endif // BluetoothAttributeInstanceMap_h |
| OLD | NEW |