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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic.cc

Issue 2826383002: bluetooth: Make in progress errors consistent across android
Patch Set: Fix windows Created 3 years, 8 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/bluetooth_remote_gatt_characteristic.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic.cc
index 9443ba97abd8ec698c24f5ca1fca2e0b0323c610..2bf85c756655d56a73af3ec0b7111fc32960149b 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic.cc
@@ -8,6 +8,7 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_notify_session.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
@@ -85,6 +86,33 @@ void BluetoothRemoteGattCharacteristic::StartNotifySession(
}
}
+void BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic(
scheib 2017/04/21 23:33:10 Consider keeping all logic in the base classes, ne
ortuno 2017/04/28 03:47:12 I was exploring something like that at some point
+ const ValueCallback& callback,
+ const ErrorCallback& error_callback) {
+ if (HasPendingGattOperation()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(error_callback,
+ BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
+ return;
+ }
+ ReadRemoteCharacteristicImpl(callback, error_callback);
+}
+
+void BluetoothRemoteGattCharacteristic::WriteRemoteCharacteristic(
+ const std::vector<uint8_t>& value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ if (HasPendingGattOperation()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(error_callback,
+ BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
+ return;
+ }
+ WriteRemoteCharacteristicImpl(value, callback, error_callback);
+}
+
void BluetoothRemoteGattCharacteristic::ExecuteStartNotifySession(
NotifySessionCallback callback,
ErrorCallback error_callback,
@@ -228,6 +256,13 @@ void BluetoothRemoteGattCharacteristic::OnStartNotifySessionError(
}
}
+bool BluetoothRemoteGattCharacteristic::HasPendingGattOperation() {
+ return GetService()->GetDevice()->HasPendingGattOperation();
+}
+void BluetoothRemoteGattCharacteristic::SetPendingGattOperation(bool pending) {
+ GetService()->GetDevice()->SetPendingGattOperation(pending);
+}
+
void BluetoothRemoteGattCharacteristic::StopNotifySession(
BluetoothGattNotifySession* session,
const base::Closure& callback) {

Powered by Google App Engine
This is Rietveld 408576698