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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2638753002: Revert of Bluetooth: macOS: BluetoothRemoteGattCharacteristicMac::SubscribeToNotifications (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5b2b14a4c50feaabb385535e89bb0cf898842b9..c04df6af94cbf836232feccfe1a9b6dd85743118 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
@@ -150,6 +150,50 @@
searched_pair->second.get());
}
+void BluetoothRemoteGattCharacteristicMac::StartNotifySession(
+ const NotifySessionCallback& callback,
+ const ErrorCallback& error_callback) {
+ if (IsNotifying()) {
+ VLOG(2) << "Already notifying. Creating notify session.";
+ std::unique_ptr<BluetoothGattNotifySession> notify_session(
+ new BluetoothGattNotifySession(weak_ptr_factory_.GetWeakPtr()));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, base::Passed(std::move(notify_session))));
+ return;
+ }
+
+ if (!SupportsNotificationsOrIndications()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(error_callback,
+ BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED));
+ return;
+ }
+
+ start_notify_session_callbacks_.push_back(
+ std::make_pair(callback, error_callback));
+
+ if (start_notifications_in_progress_) {
+ VLOG(2) << "Start Notifications already in progress. "
+ << "Request has been queued.";
+ return;
+ }
+
+ [GetCBPeripheral() setNotifyValue:YES
+ forCharacteristic:cb_characteristic_.get()];
+ start_notifications_in_progress_ = true;
+}
+
+void BluetoothRemoteGattCharacteristicMac::StopNotifySession(
+ BluetoothGattNotifySession* session,
+ const base::Closure& callback) {
+ // TODO(http://crbug.com/633191): Remove this method and use the base version.
+ // Instead, we should implement SubscribeToNotifications and
+ // UnsubscribeFromNotifications.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
+}
+
void BluetoothRemoteGattCharacteristicMac::ReadRemoteCharacteristic(
const ValueCallback& callback,
const ErrorCallback& error_callback) {
@@ -212,34 +256,8 @@
BluetoothRemoteGattDescriptor* ccc_descriptor,
const base::Closure& callback,
const ErrorCallback& error_callback) {
- if (IsNotifying()) {
- VLOG(2) << "Already notifying. Creating notify session.";
- std::unique_ptr<BluetoothGattNotifySession> notify_session(
- new BluetoothGattNotifySession(weak_ptr_factory_.GetWeakPtr()));
- callback.Run();
- return;
- }
-
- if (!SupportsNotificationsOrIndications()) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(error_callback,
- BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED));
- return;
- }
-
- start_notify_session_callbacks_.push_back(
- std::make_pair(callback, error_callback));
-
- if (start_notifications_in_progress_) {
- VLOG(2) << "Start Notifications already in progress. "
- << "Request has been queued.";
- return;
- }
-
- [GetCBPeripheral() setNotifyValue:YES
- forCharacteristic:cb_characteristic_.get()];
- start_notifications_in_progress_ = true;
+ // TODO(http://crbug.com/633191): Implement this method
+ NOTIMPLEMENTED();
}
void BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications(
@@ -318,7 +336,8 @@
void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
NSError* error) {
- std::vector<PendingStartNotifyCall> reentrant_safe_callbacks;
+ std::vector<std::pair<NotifySessionCallback, ErrorCallback>>
+ reentrant_safe_callbacks;
reentrant_safe_callbacks.swap(start_notify_session_callbacks_);
start_notifications_in_progress_ = false;
if (error) {
@@ -335,7 +354,8 @@
return;
}
for (const auto& callback : reentrant_safe_callbacks) {
- callback.first.Run();
+ callback.first.Run(base::MakeUnique<BluetoothGattNotifySession>(
+ weak_ptr_factory_.GetWeakPtr()));
}
}
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698