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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.h

Issue 2478013002: bluetooth: Invalidate services upon disconnection (Closed)
Patch Set: Address scheib's comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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/BluetoothRemoteGATTService.h" 8 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "platform/heap/Heap.h" 10 #include "platform/heap/Heap.h"
11 #include <memory> 11 #include <memory>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class BluetoothDevice; 15 class BluetoothDevice;
16 class ScriptPromiseResolver; 16 class ScriptPromiseResolver;
17 struct WebBluetoothRemoteGATTService; 17 struct WebBluetoothRemoteGATTService;
18 18
19 // Map that holds all GATT attributes, i.e. BluetoothRemoteGATTService, 19 // Map that holds all GATT attributes, i.e. BluetoothRemoteGATTService,
20 // BluetoothRemoteGATTCharacteristic, BluetoothRemoteGATTDescriptor, for 20 // BluetoothRemoteGATTCharacteristic, BluetoothRemoteGATTDescriptor, for
21 // the BluetoothDevice passed in when constructing the object. 21 // the BluetoothDevice passed in when constructing the object.
22 // Methods in this map are used to create or retrieve these attributes. 22 // Methods in this map are used to create or retrieve these attributes.
23 class BluetoothAttributeInstanceMap final 23 class BluetoothAttributeInstanceMap final
24 : public GarbageCollected<BluetoothAttributeInstanceMap> { 24 : public GarbageCollected<BluetoothAttributeInstanceMap> {
25 public: 25 public:
26 BluetoothAttributeInstanceMap(BluetoothDevice*); 26 BluetoothAttributeInstanceMap(BluetoothDevice*);
27 27
28 // Constructs a new BluetoothRemoteGATTService object if there was
29 // no service with the same instance id and adds it to the map.
30 // Otherwise returns the BluetoothRemoteGATTService object already
31 // in the map.
28 BluetoothRemoteGATTService* getOrCreateBluetoothRemoteGATTService( 32 BluetoothRemoteGATTService* getOrCreateBluetoothRemoteGATTService(
29 std::unique_ptr<WebBluetoothRemoteGATTService>); 33 std::unique_ptr<WebBluetoothRemoteGATTService>);
30 34
31 // TODO(crbug.com/654950): Implement methods to retrieve all attributes 35 // Returns true if a BluetoothRemoteGATTService with |serviceInstanceId|
32 // associated with the device. 36 // is in the map.
37 bool containsService(const String& serviceInstanceId);
38
39 // Removes all Attributes from the map.
40 // TODO(crbug.com/654950): Remove characteristics and descriptors when
41 // implemented.
42 void Clear();
33 43
34 DECLARE_VIRTUAL_TRACE(); 44 DECLARE_VIRTUAL_TRACE();
35 45
36 private: 46 private:
37 // BluetoothDevice that owns this map. 47 // BluetoothDevice that owns this map.
38 Member<BluetoothDevice> m_device; 48 Member<BluetoothDevice> m_device;
39 // Map of service instance ids to objects. 49 // Map of service instance ids to objects.
40 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject; 50 HeapHashMap<String, Member<BluetoothRemoteGATTService>> m_serviceIdToObject;
41 }; 51 };
42 52
43 } // namespace blink 53 } // namespace blink
44 54
45 #endif // BluetoothAttributeInstanceMap_h 55 #endif // BluetoothAttributeInstanceMap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698