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

Unified Diff: device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc

Issue 2051333004: Implement BluetoothGattNotifySession::Stop on Android, 2nd attempt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address new review comments Created 4 years, 4 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/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
diff --git a/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc b/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
index b1d6a0ef80fae257db6831d27233915019a03b52..8dbe316378d57836b857c6759fb4892ea006e73e 100644
--- a/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
@@ -14,9 +14,9 @@
#include "dbus/property.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_gatt_notify_session.h"
#include "device/bluetooth/bluetooth_gatt_service.h"
#include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
-#include "device/bluetooth/bluez/bluetooth_gatt_notify_session_bluez.h"
#include "device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.h"
#include "device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h"
#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
@@ -83,6 +83,44 @@ BluetoothRemoteGattCharacteristicBlueZ::
}
}
+void BluetoothRemoteGattCharacteristicBlueZ::StopNotifySession(
+ device::BluetoothGattNotifySession* session,
+ const base::Closure& callback) {
+ VLOG(1) << __func__;
+
+ if (num_notify_sessions_ > 1) {
+ DCHECK(!notify_call_pending_);
+ --num_notify_sessions_;
+ callback.Run();
+ return;
+ }
+
+ // Notifications may have stopped outside our control. If the characteristic
+ // is no longer notifying, return success.
+ if (!IsNotifying()) {
+ num_notify_sessions_ = 0;
+ callback.Run();
+ return;
+ }
+
+ if (notify_call_pending_ || num_notify_sessions_ == 0) {
+ callback.Run();
+ return;
+ }
+
+ DCHECK(num_notify_sessions_ == 1);
+ notify_call_pending_ = true;
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothGattCharacteristicClient()
+ ->StopNotify(
+ object_path(),
+ base::Bind(
+ &BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifySuccess,
+ weak_ptr_factory_.GetWeakPtr(), callback),
+ base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifyError,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
device::BluetoothUUID BluetoothRemoteGattCharacteristicBlueZ::GetUUID() const {
bluez::BluetoothGattCharacteristicClient::Properties* properties =
bluez::BluezDBusManager::Get()
@@ -206,9 +244,8 @@ void BluetoothRemoteGattCharacteristicBlueZ::StartNotifySession(
DCHECK(service_->GetAdapter());
DCHECK(service_->GetDevice());
std::unique_ptr<device::BluetoothGattNotifySession> session(
- new BluetoothGattNotifySessionBlueZ(
- service_->GetAdapter(), service_->GetDevice()->GetAddress(),
- service_->GetIdentifier(), GetIdentifier(), object_path()));
+ new device::BluetoothGattNotifySession(
+ weak_ptr_factory_.GetWeakPtr()));
callback.Run(std::move(session));
return;
}
@@ -264,41 +301,20 @@ void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic(
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
-void BluetoothRemoteGattCharacteristicBlueZ::RemoveNotifySession(
- const base::Closure& callback) {
- VLOG(1) << __func__;
-
- if (num_notify_sessions_ > 1) {
- DCHECK(!notify_call_pending_);
- --num_notify_sessions_;
- callback.Run();
- return;
- }
-
- // Notifications may have stopped outside our control. If the characteristic
- // is no longer notifying, return success.
- if (!IsNotifying()) {
- num_notify_sessions_ = 0;
- callback.Run();
- return;
- }
-
- if (notify_call_pending_ || num_notify_sessions_ == 0) {
- callback.Run();
- return;
- }
+void BluetoothRemoteGattCharacteristicBlueZ::SubscribeToNotifications(
+ device::BluetoothRemoteGattDescriptor* ccc_descriptor,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ // TODO(http://crbug.com/636275): Implement this method
+ NOTIMPLEMENTED();
+}
- DCHECK(num_notify_sessions_ == 1);
- notify_call_pending_ = true;
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->StopNotify(
- object_path(),
- base::Bind(
- &BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifySuccess,
- weak_ptr_factory_.GetWeakPtr(), callback),
- base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifyError,
- weak_ptr_factory_.GetWeakPtr(), callback));
+void BluetoothRemoteGattCharacteristicBlueZ::UnsubscribeFromNotifications(
+ device::BluetoothRemoteGattDescriptor* ccc_descriptor,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ // TODO(http://crbug.com/636275): Implement this method
+ NOTIMPLEMENTED();
}
void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorAdded(
@@ -394,9 +410,7 @@ void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifySuccess(
DCHECK(service_);
DCHECK(service_->GetDevice());
std::unique_ptr<device::BluetoothGattNotifySession> session(
- new BluetoothGattNotifySessionBlueZ(
- service_->GetAdapter(), service_->GetDevice()->GetAddress(),
- service_->GetIdentifier(), GetIdentifier(), object_path()));
+ new device::BluetoothGattNotifySession(weak_ptr_factory_.GetWeakPtr()));
callback.Run(std::move(session));
ProcessStartNotifyQueue();
« no previous file with comments | « device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698