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 |