| Index: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
|
| diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
|
| index 8e4a14dd52d75dfdf3866ffe1f357e58f7fb30ca..61432ab9d8b3e41bb97d3526fd8419043fe3258c 100644
|
| --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
|
| +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
|
| @@ -69,7 +69,9 @@ static BluetoothGattCharacteristic::Properties ConvertProperties(
|
| BluetoothRemoteGattCharacteristicMac::BluetoothRemoteGattCharacteristicMac(
|
| BluetoothRemoteGattServiceMac* gatt_service,
|
| CBCharacteristic* cb_characteristic)
|
| - : gatt_service_(gatt_service),
|
| + : is_discovery_complete_(false),
|
| + discovery_pending_count_(0),
|
| + gatt_service_(gatt_service),
|
| cb_characteristic_(cb_characteristic, base::scoped_policy::RETAIN),
|
| characteristic_value_read_or_write_in_progress_(false) {
|
| uuid_ = BluetoothAdapterMac::BluetoothUUIDWithCBUUID(
|
| @@ -245,6 +247,7 @@ void BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications(
|
| void BluetoothRemoteGattCharacteristicMac::DiscoverDescriptors() {
|
| VLOG(1) << *this << ": Discover descriptors.";
|
| is_discovery_complete_ = false;
|
| + ++discovery_pending_count_;
|
| [GetCBPeripheral()
|
| discoverDescriptorsForCharacteristic:cb_characteristic_.get()];
|
| }
|
| @@ -346,7 +349,9 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
|
|
|
| void BluetoothRemoteGattCharacteristicMac::DidDiscoverDescriptors() {
|
| DCHECK(!is_discovery_complete_);
|
| + DCHECK(discovery_pending_count_ > 0);
|
| VLOG(1) << *this << ": Did discover descriptors.";
|
| + --discovery_pending_count_;
|
| std::unordered_set<std::string> descriptor_identifier_to_remove;
|
| for (const auto& iter : gatt_descriptor_macs_) {
|
| descriptor_identifier_to_remove.insert(iter.first);
|
| @@ -379,7 +384,7 @@ void BluetoothRemoteGattCharacteristicMac::DidDiscoverDescriptors() {
|
| gatt_descriptor_macs_.erase(pair_to_remove);
|
| GetMacAdapter()->NotifyGattDescriptorRemoved(descriptor_to_remove.get());
|
| }
|
| - is_discovery_complete_ = true;
|
| + is_discovery_complete_ = discovery_pending_count_ == 0;
|
| }
|
|
|
| bool BluetoothRemoteGattCharacteristicMac::IsReadable() const {
|
|
|