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

Unified Diff: device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc

Issue 1974633002: Implement DBus changes needed for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc
diff --git a/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc
index d7acdb41c5bf41584d11328d52023ed00e5c12c9..587705b6eba5ef95f77b87e97b81166017608465 100644
--- a/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc
+++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.cc
@@ -40,9 +40,6 @@ BluetoothGattCharacteristicServiceProviderImpl::
weak_ptr_factory_(this) {
VLOG(1) << "Created Bluetooth GATT characteristic: " << object_path.value()
<< " UUID: " << uuid;
-
- // If we have a null bus, this means that this is being initialized for a
- // test, hence we shouldn't do any other setup.
if (!bus_)
return;
@@ -90,6 +87,20 @@ BluetoothGattCharacteristicServiceProviderImpl::
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
weak_ptr_factory_.GetWeakPtr()));
+ exported_object_->ExportMethod(
+ bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface,
+ bluetooth_gatt_characteristic::kStartNotify,
+ base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::StartNotify,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
+ weak_ptr_factory_.GetWeakPtr()));
+ exported_object_->ExportMethod(
+ bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface,
+ bluetooth_gatt_characteristic::kStopNotify,
+ base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::StopNotify,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
+ weak_ptr_factory_.GetWeakPtr()));
}
BluetoothGattCharacteristicServiceProviderImpl::
@@ -102,6 +113,10 @@ BluetoothGattCharacteristicServiceProviderImpl::
void BluetoothGattCharacteristicServiceProviderImpl::SendValueChanged(
const std::vector<uint8_t>& value) {
+ // Running a test, don't actually try to write to use DBus.
+ if (!bus_)
+ return;
+
VLOG(2) << "Emitting a PropertiesChanged signal for characteristic value.";
dbus::Signal signal(dbus::kDBusPropertiesInterface,
dbus::kDBusPropertiesChangedSignal);
@@ -359,6 +374,27 @@ void BluetoothGattCharacteristicServiceProviderImpl::WriteValue(
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender));
}
+void BluetoothGattCharacteristicServiceProviderImpl::StartNotify(
+ dbus::MethodCall* method_call,
+ dbus::ExportedObject::ResponseSender response_sender) {
+ VLOG(3) << "BluetoothGattCharacteristicServiceProvider::StartNotify: "
+ << object_path_.value();
+ DCHECK(OnOriginThread());
+ DCHECK(delegate_);
+ delegate_->StartNotifications();
+}
+
+void BluetoothGattCharacteristicServiceProviderImpl::StopNotify(
+ dbus::MethodCall* method_call,
+ dbus::ExportedObject::ResponseSender response_sender) {
+ VLOG(3) << "BluetoothGattCharacteristicServiceProvider::StopNotify: "
+ << object_path_.value();
+ DCHECK(OnOriginThread());
+
+ DCHECK(delegate_);
+ delegate_->StopNotifications();
+}
+
void BluetoothGattCharacteristicServiceProviderImpl::OnExported(
const std::string& interface_name,
const std::string& method_name,

Powered by Google App Engine
This is Rietveld 408576698