| 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 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool BluetoothAttributeInstanceMap::containsService( | 36 bool BluetoothAttributeInstanceMap::containsService( |
| 37 const String& serviceInstanceId) { | 37 const String& serviceInstanceId) { |
| 38 return m_serviceIdToObject.contains(serviceInstanceId); | 38 return m_serviceIdToObject.contains(serviceInstanceId); |
| 39 } | 39 } |
| 40 | 40 |
| 41 BluetoothRemoteGATTCharacteristic* | 41 BluetoothRemoteGATTCharacteristic* |
| 42 BluetoothAttributeInstanceMap::getOrCreateRemoteGATTCharacteristic( | 42 BluetoothAttributeInstanceMap::getOrCreateRemoteGATTCharacteristic( |
| 43 ExecutionContext* context, | 43 ExecutionContext* context, |
| 44 const String& serviceInstanceId, | |
| 45 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr | 44 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr |
| 46 remoteGATTCharacteristic, | 45 remoteGATTCharacteristic, |
| 47 BluetoothRemoteGATTService* service) { | 46 BluetoothRemoteGATTService* service) { |
| 48 String instanceId = remoteGATTCharacteristic->instance_id; | 47 String instanceId = remoteGATTCharacteristic->instance_id; |
| 49 BluetoothRemoteGATTCharacteristic* characteristic = | 48 BluetoothRemoteGATTCharacteristic* characteristic = |
| 50 m_characteristicIdToObject.get(instanceId); | 49 m_characteristicIdToObject.get(instanceId); |
| 51 | 50 |
| 52 if (!characteristic) { | 51 if (!characteristic) { |
| 53 characteristic = BluetoothRemoteGATTCharacteristic::create( | 52 characteristic = BluetoothRemoteGATTCharacteristic::create( |
| 54 context, serviceInstanceId, std::move(remoteGATTCharacteristic), | 53 context, std::move(remoteGATTCharacteristic), service, m_device); |
| 55 service, m_device); | |
| 56 m_characteristicIdToObject.add(instanceId, characteristic); | 54 m_characteristicIdToObject.add(instanceId, characteristic); |
| 57 } | 55 } |
| 58 | 56 |
| 59 return characteristic; | 57 return characteristic; |
| 60 } | 58 } |
| 61 | 59 |
| 62 bool BluetoothAttributeInstanceMap::containsCharacteristic( | 60 bool BluetoothAttributeInstanceMap::containsCharacteristic( |
| 63 const String& characteristicInstanceId) { | 61 const String& characteristicInstanceId) { |
| 64 return m_characteristicIdToObject.contains(characteristicInstanceId); | 62 return m_characteristicIdToObject.contains(characteristicInstanceId); |
| 65 } | 63 } |
| 66 | 64 |
| 67 void BluetoothAttributeInstanceMap::Clear() { | 65 void BluetoothAttributeInstanceMap::Clear() { |
| 68 m_serviceIdToObject.clear(); | 66 m_serviceIdToObject.clear(); |
| 69 m_characteristicIdToObject.clear(); | 67 m_characteristicIdToObject.clear(); |
| 70 } | 68 } |
| 71 | 69 |
| 72 DEFINE_TRACE(BluetoothAttributeInstanceMap) { | 70 DEFINE_TRACE(BluetoothAttributeInstanceMap) { |
| 73 visitor->trace(m_device); | 71 visitor->trace(m_device); |
| 74 visitor->trace(m_serviceIdToObject); | 72 visitor->trace(m_serviceIdToObject); |
| 75 visitor->trace(m_characteristicIdToObject); | 73 visitor->trace(m_characteristicIdToObject); |
| 76 } | 74 } |
| 77 | 75 |
| 78 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |