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

Unified Diff: chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc

Issue 788193004: chromeos/dbus: Update Bluetooth GATT API clients to upstream definition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & tbr Created 5 years, 10 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: chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
index ec04474634da320affc74545fa2ed43fe2bdda3c..1f3a9bf93345eb013626d88bb4b88480fc6298a9 100644
--- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
+++ b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
@@ -176,14 +176,16 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
}
return;
}
+
base::Closure completed_callback;
if (!IsHeartRateVisible()) {
completed_callback =
base::Bind(error_callback, kUnknownCharacteristicError, "");
} else {
- std::vector<uint8> value;
- value.push_back(0x06); // Location is "foot".
- completed_callback = base::Bind(callback, value);
+ std::vector<uint8> value = {0x06}; // Location is "foot".
+ completed_callback = base::Bind(
+ &FakeBluetoothGattCharacteristicClient::DelayedReadValueCallback,
+ weak_ptr_factory_.GetWeakPtr(), object_path, callback, value);
}
if (extra_requests_ > 0) {
@@ -191,6 +193,7 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
new DelayedCallback(completed_callback, extra_requests_);
return;
}
+
completed_callback.Run();
}
@@ -488,12 +491,7 @@ void FakeBluetoothGattCharacteristicClient::
VLOG(2) << "Updating heart rate value.";
std::vector<uint8> measurement = GetHeartRateMeasurementValue();
-
- FOR_EACH_OBSERVER(
- BluetoothGattCharacteristicClient::Observer,
- observers_,
- GattCharacteristicValueUpdated(
- dbus::ObjectPath(heart_rate_measurement_path_), measurement));
+ heart_rate_measurement_properties_->value.ReplaceValue(measurement);
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
@@ -504,6 +502,17 @@ void FakeBluetoothGattCharacteristicClient::
kHeartRateMeasurementNotificationIntervalMs));
}
+void FakeBluetoothGattCharacteristicClient::DelayedReadValueCallback(
+ const dbus::ObjectPath& object_path,
+ const ValueCallback& callback,
+ const std::vector<uint8_t>& value) {
+ Properties* properties = GetProperties(object_path);
+ DCHECK(properties);
+
+ properties->value.ReplaceValue(value);
+ callback.Run(value);
+}
+
std::vector<uint8>
FakeBluetoothGattCharacteristicClient::GetHeartRateMeasurementValue() {
// TODO(armansito): We should make sure to properly pack this struct to ensure
« no previous file with comments | « chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h ('k') | chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698