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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2745983003: Bluetooth: macOS: Adding logs (Closed)
Patch Set: Changing GetIdentifier() by GetUUID() + pointer Created 3 years, 9 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_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 2e2da4e618c0214d4907811847147a72b587390d..0e860b5ed85a2eed0110ad67c37918864b1f204a 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
@@ -152,6 +152,7 @@ void BluetoothRemoteGattCharacteristicMac::ReadRemoteCharacteristic(
const ValueCallback& callback,
const ErrorCallback& error_callback) {
if (!IsReadable()) {
+ VLOG(1) << *this << ": Characteristic not readable.";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(error_callback,
@@ -159,12 +160,14 @@ void BluetoothRemoteGattCharacteristicMac::ReadRemoteCharacteristic(
return;
}
if (characteristic_value_read_or_write_in_progress_) {
+ VLOG(1) << *this << ": Characteristic read already in progress.";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
return;
}
+ VLOG(1) << *this << ": Read characteristic.";
characteristic_value_read_or_write_in_progress_ = true;
read_characteristic_value_callbacks_ =
std::make_pair(callback, error_callback);
@@ -176,6 +179,7 @@ void BluetoothRemoteGattCharacteristicMac::WriteRemoteCharacteristic(
const base::Closure& callback,
const ErrorCallback& error_callback) {
if (!IsWritable()) {
+ VLOG(1) << *this << ": Characteristic not writable.";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(error_callback,
@@ -183,12 +187,14 @@ void BluetoothRemoteGattCharacteristicMac::WriteRemoteCharacteristic(
return;
}
if (characteristic_value_read_or_write_in_progress_) {
+ VLOG(1) << *this << ": Characteristic write already in progress.";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
return;
}
+ VLOG(1) << *this << ": Write characteristic.";
characteristic_value_read_or_write_in_progress_ = true;
write_characteristic_value_callbacks_ =
std::make_pair(callback, error_callback);
@@ -210,6 +216,7 @@ void BluetoothRemoteGattCharacteristicMac::SubscribeToNotifications(
BluetoothRemoteGattDescriptor* ccc_descriptor,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ VLOG(1) << *this << ": Subscribe to characteristic.";
DCHECK(subscribe_to_notification_callbacks_.first.is_null());
DCHECK(subscribe_to_notification_callbacks_.second.is_null());
DCHECK(unsubscribe_from_notification_callbacks_.first.is_null());
@@ -224,6 +231,7 @@ void BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications(
BluetoothRemoteGattDescriptor* ccc_descriptor,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ VLOG(1) << *this << ": Unsubscribe from characteristic.";
DCHECK(subscribe_to_notification_callbacks_.first.is_null());
DCHECK(subscribe_to_notification_callbacks_.second.is_null());
DCHECK(unsubscribe_from_notification_callbacks_.first.is_null());
@@ -235,6 +243,7 @@ void BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications(
}
void BluetoothRemoteGattCharacteristicMac::DiscoverDescriptors() {
+ VLOG(1) << *this << ": Discover descriptors.";
is_discovery_complete_ = false;
[GetCBPeripheral()
discoverDescriptorsForCharacteristic:cb_characteristic_.get()];
@@ -249,7 +258,8 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateValue(NSError* error) {
callbacks.swap(read_characteristic_value_callbacks_);
characteristic_value_read_or_write_in_progress_ = false;
if (error) {
- VLOG(1) << "Bluetooth error while reading for characteristic, domain: "
+ VLOG(1) << *this
+ << ": Bluetooth error while reading for characteristic, domain: "
<< base::SysNSStringToUTF8(error.domain)
<< ", error code: " << error.code;
BluetoothGattService::GattErrorCode error_code =
@@ -257,17 +267,21 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateValue(NSError* error) {
callbacks.second.Run(error_code);
return;
}
+ VLOG(1) << *this << ": Read request arrived.";
UpdateValue();
callbacks.first.Run(value_);
} else if (IsNotifying()) {
+ VLOG(1) << *this << ": Notification arrived.";
UpdateValue();
gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(
this, value_);
} else {
// In case of buggy device, nothing should be done if receiving extra
// read confirmation.
- VLOG(1) << "Characteristic value updated while having no pending read nor "
- "notification.";
+ VLOG(1)
+ << *this
+ << ": Characteristic value updated while having no pending read nor "
+ "notification.";
}
}
@@ -282,14 +296,16 @@ void BluetoothRemoteGattCharacteristicMac::DidWriteValue(NSError* error) {
if (!characteristic_value_read_or_write_in_progress_) {
// In case of buggy device, nothing should be done if receiving extra
// write confirmation.
- VLOG(1) << "Write notification while no write operation pending.";
+ VLOG(1) << *this
+ << ": Write notification while no write operation pending.";
return;
}
std::pair<base::Closure, ErrorCallback> callbacks;
callbacks.swap(write_characteristic_value_callbacks_);
characteristic_value_read_or_write_in_progress_ = false;
if (error) {
- VLOG(1) << "Bluetooth error while writing for characteristic, domain: "
+ VLOG(1) << *this
+ << ": Bluetooth error while writing for characteristic, domain: "
<< base::SysNSStringToUTF8(error.domain)
<< ", error code: " << error.code;
BluetoothGattService::GattErrorCode error_code =
@@ -297,6 +313,7 @@ void BluetoothRemoteGattCharacteristicMac::DidWriteValue(NSError* error) {
callbacks.second.Run(error_code);
return;
}
+ VLOG(1) << *this << ": Write value succeeded.";
callbacks.first.Run();
}
@@ -310,12 +327,12 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
DCHECK(![GetCBCharacteristic() isNotifying] || error);
reentrant_safe_callbacks.swap(unsubscribe_from_notification_callbacks_);
} else {
- VLOG(1) << "No pending notification update for characteristic "
- << GetUUID().value();
+ VLOG(1) << *this << ": No pending notification update for characteristic.";
return;
}
if (error) {
- VLOG(1) << "Bluetooth error while modifying notification state for "
+ VLOG(1) << *this
+ << ": Bluetooth error while modifying notification state for "
"characteristic, domain: "
<< base::SysNSStringToUTF8(error.domain)
<< ", error code: " << error.code << ", localized description: "
@@ -330,6 +347,7 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
void BluetoothRemoteGattCharacteristicMac::DidDiscoverDescriptors() {
DCHECK(!is_discovery_complete_);
+ VLOG(1) << *this << ": Did discover descriptors.";
std::unordered_set<std::string> descriptor_identifier_to_remove;
for (const auto& iter : gatt_descriptor_macs_) {
descriptor_identifier_to_remove.insert(iter.first);
@@ -339,6 +357,7 @@ void BluetoothRemoteGattCharacteristicMac::DidDiscoverDescriptors() {
BluetoothRemoteGattDescriptorMac* gatt_descriptor_mac =
GetBluetoothRemoteGattDescriptorMac(cb_descriptor);
if (gatt_descriptor_mac) {
+ VLOG(1) << *gatt_descriptor_mac << ": Known descriptor.";
const std::string& identifier = gatt_descriptor_mac->GetIdentifier();
descriptor_identifier_to_remove.erase(identifier);
continue;
@@ -350,11 +369,13 @@ void BluetoothRemoteGattCharacteristicMac::DidDiscoverDescriptors() {
{identifier, base::WrapUnique(gatt_descriptor_mac)});
DCHECK(result_iter.second);
GetMacAdapter()->NotifyGattDescriptorAdded(gatt_descriptor_mac);
+ VLOG(1) << *gatt_descriptor_mac << ": New descriptor.";
}
for (const std::string& identifier : descriptor_identifier_to_remove) {
auto pair_to_remove = gatt_descriptor_macs_.find(identifier);
std::unique_ptr<BluetoothRemoteGattDescriptorMac> descriptor_to_remove;
+ VLOG(1) << *descriptor_to_remove << ": Removed descriptor.";
pair_to_remove->second.swap(descriptor_to_remove);
gatt_descriptor_macs_.erase(pair_to_remove);
GetMacAdapter()->NotifyGattDescriptorRemoved(descriptor_to_remove.get());
@@ -420,4 +441,17 @@ BluetoothRemoteGattCharacteristicMac::GetBluetoothRemoteGattDescriptorMac(
return found->second.get();
}
}
+
+DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<(
+ std::ostream& out,
+ const BluetoothRemoteGattCharacteristicMac& characteristic) {
+ const BluetoothRemoteGattServiceMac* service_mac =
+ static_cast<const BluetoothRemoteGattServiceMac*>(
+ characteristic.GetService());
+ return out << "<BluetoothRemoteGattCharacteristicMac "
+ << characteristic.GetUUID().canonical_value() << "/"
+ << &characteristic
+ << ", service: " << service_mac->GetUUID().canonical_value() << "/"
+ << service_mac << ">";
+}
} // namespace device.
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h ('k') | device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698