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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2347133002: bluetooth: Call error callback when characteristics get destroyed during a GATT Event (mac) (Closed)
Patch Set: Improve comments Created 4 years, 3 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ffa4ad601678c1ef63e5d64d42da5f7acea87141..db28fb9df011cd396d3b02e91cee3369fc45dede 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
@@ -80,7 +80,18 @@ BluetoothRemoteGattCharacteristicMac::BluetoothRemoteGattCharacteristicMac(
(void*)cb_characteristic_]);
}
-BluetoothRemoteGattCharacteristicMac::~BluetoothRemoteGattCharacteristicMac() {}
+BluetoothRemoteGattCharacteristicMac::~BluetoothRemoteGattCharacteristicMac() {
+ if (!read_characteristic_value_callbacks_.first.is_null()) {
+ std::pair<ValueCallback, ErrorCallback> callbacks;
+ callbacks.swap(read_characteristic_value_callbacks_);
+ callbacks.second.Run(BluetoothGattService::GATT_ERROR_FAILED);
+ }
+ if (!write_characteristic_value_callbacks_.first.is_null()) {
+ std::pair<base::Closure, ErrorCallback> callbacks;
+ callbacks.swap(write_characteristic_value_callbacks_);
+ callbacks.second.Run(BluetoothGattService::GATT_ERROR_FAILED);
+ }
+}
std::string BluetoothRemoteGattCharacteristicMac::GetIdentifier() const {
return identifier_;
@@ -249,6 +260,7 @@ void BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications(
}
void BluetoothRemoteGattCharacteristicMac::DidUpdateValue(NSError* error) {
+ CHECK_EQ(gatt_service_->GetCBPeripheral().state, CBPeripheralStateConnected);
// This method is called when the characteristic is read and when a
// notification is received.
if (characteristic_value_read_or_write_in_progress_) {
@@ -285,6 +297,7 @@ void BluetoothRemoteGattCharacteristicMac::UpdateValueAndNotify() {
}
void BluetoothRemoteGattCharacteristicMac::DidWriteValue(NSError* error) {
+ CHECK_EQ(gatt_service_->GetCBPeripheral().state, CBPeripheralStateConnected);
if (!characteristic_value_read_or_write_in_progress_) {
// In case of buggy device, nothing should be done if receiving extra
// write confirmation.
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698