Index: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc |
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc |
index 49af8d2c680b5c6cdbef8be71430666bdacfa5bb..9050fe56512e3148004b78abc207e5fbe8dbf89a 100644 |
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc |
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc |
@@ -128,16 +128,10 @@ BluetoothRemoteGattCharacteristicAndroid::GetDescriptor( |
return iter->second.get(); |
} |
-void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic( |
+void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristicImpl( |
const ValueCallback& callback, |
const ErrorCallback& error_callback) { |
- if (read_pending_ || write_pending_) { |
- base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, |
- base::Bind(error_callback, |
- BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); |
- return; |
- } |
+ DCHECK(!HasPendingGattOperation()); |
scheib
2017/04/21 23:33:11
Drop reference to base class details and check the
|
if (!Java_ChromeBluetoothRemoteGattCharacteristic_readRemoteCharacteristic( |
AttachCurrentThread(), j_characteristic_)) { |
@@ -147,22 +141,16 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic( |
return; |
} |
- read_pending_ = true; |
+ SetPendingGattOperation(true); |
read_callback_ = callback; |
read_error_callback_ = error_callback; |
} |
-void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( |
+void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristicImpl( |
const std::vector<uint8_t>& value, |
const base::Closure& callback, |
const ErrorCallback& error_callback) { |
- if (read_pending_ || write_pending_) { |
- base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, |
- base::Bind(error_callback, |
- BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); |
- return; |
- } |
+ DCHECK(!HasPendingGattOperation()); |
JNIEnv* env = AttachCurrentThread(); |
if (!Java_ChromeBluetoothRemoteGattCharacteristic_writeRemoteCharacteristic( |
@@ -173,7 +161,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( |
return; |
} |
- write_pending_ = true; |
+ SetPendingGattOperation(true); |
write_callback_ = callback; |
write_error_callback_ = error_callback; |
} |
@@ -191,7 +179,7 @@ void BluetoothRemoteGattCharacteristicAndroid::OnRead( |
const JavaParamRef<jobject>& jcaller, |
int32_t status, |
const JavaParamRef<jbyteArray>& value) { |
- read_pending_ = false; |
+ SetPendingGattOperation(false); |
// Clear callbacks before calling to avoid reentrancy issues. |
ValueCallback read_callback = read_callback_; |
@@ -213,7 +201,7 @@ void BluetoothRemoteGattCharacteristicAndroid::OnWrite( |
JNIEnv* env, |
const JavaParamRef<jobject>& jcaller, |
int32_t status) { |
- write_pending_ = false; |
+ SetPendingGattOperation(false); |
// Clear callbacks before calling to avoid reentrancy issues. |
base::Closure write_callback = write_callback_; |