| 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> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 BluetoothAttributeInstanceMap::BluetoothAttributeInstanceMap( | 14 BluetoothAttributeInstanceMap::BluetoothAttributeInstanceMap( |
| 15 BluetoothDevice* device) | 15 BluetoothDevice* device) |
| 16 : m_device(device) {} | 16 : m_device(device) {} |
| 17 | 17 |
| 18 BluetoothRemoteGATTService* | 18 BluetoothRemoteGATTService* |
| 19 BluetoothAttributeInstanceMap::getOrCreateBluetoothRemoteGATTService( | 19 BluetoothAttributeInstanceMap::getOrCreateRemoteGATTService( |
| 20 const String& serviceInstanceId, | 20 const String& serviceInstanceId, |
| 21 const String& uuid, | 21 const String& uuid, |
| 22 bool isPrimary, | 22 bool isPrimary, |
| 23 const String& deviceInstanceId) { | 23 const String& deviceInstanceId) { |
| 24 BluetoothRemoteGATTService* service = | 24 BluetoothRemoteGATTService* service = |
| 25 m_serviceIdToObject.get(serviceInstanceId); | 25 m_serviceIdToObject.get(serviceInstanceId); |
| 26 | 26 |
| 27 if (!service) { | 27 if (!service) { |
| 28 service = new BluetoothRemoteGATTService(serviceInstanceId, uuid, isPrimary, | 28 service = new BluetoothRemoteGATTService(serviceInstanceId, uuid, isPrimary, |
| 29 deviceInstanceId, m_device); | 29 deviceInstanceId, m_device); |
| 30 m_serviceIdToObject.add(serviceInstanceId, service); | 30 m_serviceIdToObject.add(serviceInstanceId, service); |
| 31 } | 31 } |
| 32 | 32 |
| 33 return service; | 33 return service; |
| 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::getOrCreateBluetoothRemoteGATTCharacteristic( | 42 BluetoothAttributeInstanceMap::getOrCreateRemoteGATTCharacteristic( |
| 43 ExecutionContext* context, | 43 ExecutionContext* context, |
| 44 const String& characteristicInstanceId, | 44 const String& characteristicInstanceId, |
| 45 const String& serviceInstanceId, | 45 const String& serviceInstanceId, |
| 46 const String& uuid, | 46 const String& uuid, |
| 47 uint32_t characteristicProperties, | 47 uint32_t characteristicProperties, |
| 48 BluetoothRemoteGATTService* service) { | 48 BluetoothRemoteGATTService* service) { |
| 49 BluetoothRemoteGATTCharacteristic* characteristic = | 49 BluetoothRemoteGATTCharacteristic* characteristic = |
| 50 m_characteristicIdToObject.get(characteristicInstanceId); | 50 m_characteristicIdToObject.get(characteristicInstanceId); |
| 51 | 51 |
| 52 if (!characteristic) { | 52 if (!characteristic) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 m_characteristicIdToObject.clear(); | 69 m_characteristicIdToObject.clear(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 DEFINE_TRACE(BluetoothAttributeInstanceMap) { | 72 DEFINE_TRACE(BluetoothAttributeInstanceMap) { |
| 73 visitor->trace(m_device); | 73 visitor->trace(m_device); |
| 74 visitor->trace(m_serviceIdToObject); | 74 visitor->trace(m_serviceIdToObject); |
| 75 visitor->trace(m_characteristicIdToObject); | 75 visitor->trace(m_characteristicIdToObject); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |