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

Unified Diff: device/bluetooth/bluetooth_low_energy_device_mac.mm

Issue 2638653002: Bluetooth: macOS: DidModifyServices can happens while scanning (Closed)
Patch Set: Merge Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_low_energy_device_mac.mm
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm
index 20694e4953b97d7ca5d4edc882a0a4b0aab06864..cff6ee533c6ecba3f9d00664ee6a6913532e4be5 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -189,7 +189,7 @@ void BluetoothLowEnergyDeviceMac::DisconnectGatt() {
void BluetoothLowEnergyDeviceMac::DidDiscoverPrimaryServices(NSError* error) {
--discovery_pending_count_;
if (discovery_pending_count_ < 0) {
- // This should never happens, just in case it happens with a device,
+ // This should never happen, just in case it happens with a device,
// discovery_pending_count_ is set back to 0.
VLOG(1) << *this
<< ": BluetoothLowEnergyDeviceMac::discovery_pending_count_ "
@@ -256,6 +256,13 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverCharacteristics(
// Don't create characteristics if the device disconnected.
return;
}
+ if (IsGattServicesDiscoveryComplete()) {
+ // This should never happen, just in case it happens with a device, this
+ // notification should be ignored.
+ VLOG(1) << *this
+ << ": Discovery complete, ignoring DidDiscoverCharacteristics.";
+ return;
+ }
BluetoothRemoteGattServiceMac* gatt_service =
GetBluetoothRemoteGattService(cb_service);
@@ -327,6 +334,13 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverDescriptors(
// Don't discover descriptors if the device disconnected.
return;
}
+ if (IsGattServicesDiscoveryComplete()) {
+ // This should never happen, just in case it happens with a device, this
+ // notification should be ignored.
+ VLOG(1) << *this
+ << ": Discovery complete, ignoring DidDiscoverDescriptors.";
+ return;
+ }
BluetoothRemoteGattServiceMac* gatt_service =
GetBluetoothRemoteGattService(cb_characteristic.service);
DCHECK(gatt_service);
@@ -380,6 +394,7 @@ void BluetoothLowEnergyDeviceMac::DiscoverPrimaryServices() {
}
void BluetoothLowEnergyDeviceMac::SendNotificationIfDiscoveryComplete() {
+ DCHECK(!IsGattServicesDiscoveryComplete());
// Notify when all services have been discovered.
bool discovery_complete =
discovery_pending_count_ == 0 &&
« no previous file with comments | « device/bluetooth/bluetooth_device_unittest.cc ('k') | device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698