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 25 matching lines...) Expand all Loading... |
44 // the map. | 45 // the map. |
45 BluetoothRemoteGATTCharacteristic* getOrCreateRemoteGATTCharacteristic( | 46 BluetoothRemoteGATTCharacteristic* getOrCreateRemoteGATTCharacteristic( |
46 ExecutionContext*, | 47 ExecutionContext*, |
47 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr, | 48 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr, |
48 BluetoothRemoteGATTService*); | 49 BluetoothRemoteGATTService*); |
49 | 50 |
50 // Returns true if a BluetoothRemoteGATTCharacteristic with | 51 // Returns true if a BluetoothRemoteGATTCharacteristic with |
51 // |characteristicInstanceId| is in the map. | 52 // |characteristicInstanceId| is in the map. |
52 bool containsCharacteristic(const String& characteristicInstanceId); | 53 bool containsCharacteristic(const String& characteristicInstanceId); |
53 | 54 |
| 55 // Constructs a new BluetoothRemoteGATTDescriptor object if there was no |
| 56 // descriptor with the same instance id and adds it to the map. |
| 57 // Otherwise returns the BluetoothRemoteGATTDescriptor object already in |
| 58 // the map. |
| 59 BluetoothRemoteGATTDescriptor* getOrCreateBluetoothRemoteGATTDescriptor( |
| 60 mojom::blink::WebBluetoothRemoteGATTDescriptorPtr, |
| 61 BluetoothRemoteGATTCharacteristic*); |
| 62 |
| 63 // Returns true if a BluetoothRemoteGATTDescriptor with |
| 64 // |descriptorInstanceId| is in the map. |
| 65 bool containsDescriptor(const String& descriptorInstanceId); |
| 66 |
54 // Removes all Attributes from the map. | 67 // Removes all Attributes from the map. |
55 // TODO(crbug.com/654950): Remove descriptors when implemented. | 68 // TODO(crbug.com/654950): Remove descriptors when implemented. |
56 void Clear(); | 69 void Clear(); |
57 | 70 |
58 DECLARE_VIRTUAL_TRACE(); | 71 DECLARE_VIRTUAL_TRACE(); |
59 | 72 |
60 private: | 73 private: |
61 // BluetoothDevice that owns this map. | 74 // BluetoothDevice that owns this map. |
62 Member<BluetoothDevice> m_device; | 75 Member<BluetoothDevice> m_device; |
63 // Map of service instance ids to objects. | 76 // Map of service instance ids to objects. |
64 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject; | 77 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject; |
65 // Map of characteristic instance ids to objects. | 78 // Map of characteristic instance ids to objects. |
66 HeapHashMap<String, Member<BluetoothRemoteGATTCharacteristic>> | 79 HeapHashMap<String, Member<BluetoothRemoteGATTCharacteristic>> |
67 m_characteristicIdToObject; | 80 m_characteristicIdToObject; |
| 81 // Map of descriptor instance ids to objects. |
| 82 HeapHashMap<String, Member<BluetoothRemoteGATTDescriptor>> |
| 83 m_descriptorIdToObject; |
68 }; | 84 }; |
69 | 85 |
70 } // namespace blink | 86 } // namespace blink |
71 | 87 |
72 #endif // BluetoothAttributeInstanceMap_h | 88 #endif // BluetoothAttributeInstanceMap_h |
OLD | NEW |