Chromium Code Reviews| Index: device/bluetooth/bluetooth_remote_gatt_service_mac.mm |
| diff --git a/device/bluetooth/bluetooth_remote_gatt_service_mac.mm b/device/bluetooth/bluetooth_remote_gatt_service_mac.mm |
| index 2e840703e40d32391166aa9f42ca0fcaa277b2ab..f7b87ee5d1838eefefda15fe63d80779eb4de732 100644 |
| --- a/device/bluetooth/bluetooth_remote_gatt_service_mac.mm |
| +++ b/device/bluetooth/bluetooth_remote_gatt_service_mac.mm |
| @@ -8,8 +8,10 @@ |
| #include <vector> |
| #include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| #include "device/bluetooth/bluetooth_adapter_mac.h" |
| #include "device/bluetooth/bluetooth_low_energy_device_mac.h" |
| +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h" |
| #include "device/bluetooth/bluetooth_uuid.h" |
| namespace device { |
| @@ -20,7 +22,8 @@ BluetoothRemoteGattServiceMac::BluetoothRemoteGattServiceMac( |
| bool is_primary) |
| : bluetooth_device_mac_(bluetooth_device_mac), |
| service_(service, base::scoped_policy::RETAIN), |
| - is_primary_(is_primary) { |
| + is_primary_(is_primary), |
| + is_discovery_complete_(false) { |
| uuid_ = BluetoothAdapterMac::BluetoothUUIDWithCBUUID([service_.get() UUID]); |
| identifier_ = |
| [NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(), |
| @@ -48,8 +51,13 @@ BluetoothDevice* BluetoothRemoteGattServiceMac::GetDevice() const { |
| std::vector<BluetoothRemoteGattCharacteristic*> |
| BluetoothRemoteGattServiceMac::GetCharacteristics() const { |
| - NOTIMPLEMENTED(); |
| - return std::vector<BluetoothRemoteGattCharacteristic*>(); |
| + std::vector<BluetoothRemoteGattCharacteristic*> gatt_characteristics; |
| + for (const auto& iter : gatt_characteristic_macs_) { |
| + BluetoothRemoteGattCharacteristic* gatt_characteristic = |
| + (BluetoothRemoteGattCharacteristic*)(iter.second); |
|
scheib
2016/06/10 21:59:31
use static_cast<> instead of C-style cast. But, in
jlebel
2016/06/10 23:02:46
Done.
|
| + gatt_characteristics.push_back(gatt_characteristic); |
| + } |
| + return gatt_characteristics; |
| } |
| std::vector<BluetoothRemoteGattService*> |
| @@ -61,8 +69,22 @@ BluetoothRemoteGattServiceMac::GetIncludedServices() const { |
| BluetoothRemoteGattCharacteristic* |
| BluetoothRemoteGattServiceMac::GetCharacteristic( |
| const std::string& identifier) const { |
| - NOTIMPLEMENTED(); |
| - return nullptr; |
| + return (BluetoothRemoteGattCharacteristic*)(gatt_characteristic_macs_.get( |
| + identifier)); |
| +} |
| + |
| +void BluetoothRemoteGattServiceMac::DidDiscoverCharacteristics() { |
|
scheib
2016/06/10 21:59:31
Are we sure this is called only once? DCHECK(!is_d
jlebel
2016/06/10 23:02:46
Done.
|
| + for (CBCharacteristic* cb_characteristic in GetService().characteristics) { |
| + BluetoothRemoteGattCharacteristicMac* gatt_characteristic_mac = |
| + new BluetoothRemoteGattCharacteristicMac(this, cb_characteristic); |
| + gatt_characteristic_macs_.add(gatt_characteristic_mac->GetIdentifier(), |
| + base::WrapUnique(gatt_characteristic_mac)); |
| + } |
| + is_discovery_complete_ = true; |
| +} |
| + |
| +bool BluetoothRemoteGattServiceMac::IsDiscoveryComplete() { |
| + return is_discovery_complete_; |
| } |
| CBService* BluetoothRemoteGattServiceMac::GetService() const { |