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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc

Issue 2287273002: Remove TODOs that are out of date. (Closed)
Patch Set: Fix a compile error on mac Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 BluetoothRemoteGattService::GATT_ERROR_FAILED)); 134 BluetoothRemoteGattService::GATT_ERROR_FAILED));
135 return; 135 return;
136 } 136 }
137 137
138 read_pending_ = true; 138 read_pending_ = true;
139 read_callback_ = callback; 139 read_callback_ = callback;
140 read_error_callback_ = error_callback; 140 read_error_callback_ = error_callback;
141 } 141 }
142 142
143 void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( 143 void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
144 const std::vector<uint8_t>& new_value, 144 const std::vector<uint8_t>& value,
145 const base::Closure& callback, 145 const base::Closure& callback,
146 const ErrorCallback& error_callback) { 146 const ErrorCallback& error_callback) {
147 if (read_pending_ || write_pending_) { 147 if (read_pending_ || write_pending_) {
148 base::ThreadTaskRunnerHandle::Get()->PostTask( 148 base::ThreadTaskRunnerHandle::Get()->PostTask(
149 FROM_HERE, 149 FROM_HERE,
150 base::Bind(error_callback, 150 base::Bind(error_callback,
151 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); 151 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
152 return; 152 return;
153 } 153 }
154 154
155 JNIEnv* env = AttachCurrentThread(); 155 JNIEnv* env = AttachCurrentThread();
156 if (!Java_ChromeBluetoothRemoteGattCharacteristic_writeRemoteCharacteristic( 156 if (!Java_ChromeBluetoothRemoteGattCharacteristic_writeRemoteCharacteristic(
157 env, j_characteristic_, 157 env, j_characteristic_, base::android::ToJavaByteArray(env, value))) {
158 base::android::ToJavaByteArray(env, new_value))) {
159 base::ThreadTaskRunnerHandle::Get()->PostTask( 158 base::ThreadTaskRunnerHandle::Get()->PostTask(
160 FROM_HERE, base::Bind(error_callback, 159 FROM_HERE, base::Bind(error_callback,
161 BluetoothRemoteGattService::GATT_ERROR_FAILED)); 160 BluetoothRemoteGattService::GATT_ERROR_FAILED));
162 return; 161 return;
163 } 162 }
164 163
165 write_pending_ = true; 164 write_pending_ = true;
166 write_callback_ = callback; 165 write_callback_ = callback;
167 write_error_callback_ = error_callback; 166 write_error_callback_ = error_callback;
168 } 167 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 206
208 // Clear callbacks before calling to avoid reentrancy issues. 207 // Clear callbacks before calling to avoid reentrancy issues.
209 base::Closure write_callback = write_callback_; 208 base::Closure write_callback = write_callback_;
210 ErrorCallback write_error_callback = write_error_callback_; 209 ErrorCallback write_error_callback = write_error_callback_;
211 write_callback_.Reset(); 210 write_callback_.Reset();
212 write_error_callback_.Reset(); 211 write_error_callback_.Reset();
213 212
214 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS 213 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS
215 && !write_callback.is_null()) { 214 && !write_callback.is_null()) {
216 write_callback.Run(); 215 write_callback.Run();
217 // TODO(https://crbug.com/545682): Call GattCharacteristicValueChanged.
218 } else if (!write_error_callback.is_null()) { 216 } else if (!write_error_callback.is_null()) {
219 write_error_callback.Run( 217 write_error_callback.Run(
220 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); 218 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));
221 } 219 }
222 } 220 }
223 221
224 void BluetoothRemoteGattCharacteristicAndroid::CreateGattRemoteDescriptor( 222 void BluetoothRemoteGattCharacteristicAndroid::CreateGattRemoteDescriptor(
225 JNIEnv* env, 223 JNIEnv* env,
226 const JavaParamRef<jobject>& caller, 224 const JavaParamRef<jobject>& caller,
227 const JavaParamRef<jstring>& instanceId, 225 const JavaParamRef<jstring>& instanceId,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() 288 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated()
291 const { 289 const {
292 if (!descriptors_.empty()) 290 if (!descriptors_.empty())
293 return; 291 return;
294 292
295 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( 293 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors(
296 AttachCurrentThread(), j_characteristic_); 294 AttachCurrentThread(), j_characteristic_);
297 } 295 }
298 296
299 } // namespace device 297 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698