| OLD | NEW |
| 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" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "device/bluetooth/bluetooth_adapter_android.h" | 18 #include "device/bluetooth/bluetooth_adapter_android.h" |
| 18 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h" | 19 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h" |
| 19 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h" | 20 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h" |
| 20 #include "jni/ChromeBluetoothRemoteGattCharacteristic_jni.h" | 21 #include "jni/ChromeBluetoothRemoteGattCharacteristic_jni.h" |
| 21 | 22 |
| 22 using base::android::AttachCurrentThread; | 23 using base::android::AttachCurrentThread; |
| 23 using base::android::JavaParamRef; | 24 using base::android::JavaParamRef; |
| 24 using base::android::JavaRef; | 25 using base::android::JavaRef; |
| 25 | 26 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 JNIEnv* env, | 235 JNIEnv* env, |
| 235 const JavaParamRef<jobject>& caller, | 236 const JavaParamRef<jobject>& caller, |
| 236 const JavaParamRef<jstring>& instanceId, | 237 const JavaParamRef<jstring>& instanceId, |
| 237 const JavaParamRef<jobject>& /* BluetoothGattDescriptorWrapper */ | 238 const JavaParamRef<jobject>& /* BluetoothGattDescriptorWrapper */ |
| 238 bluetooth_gatt_descriptor_wrapper, | 239 bluetooth_gatt_descriptor_wrapper, |
| 239 const JavaParamRef<jobject>& /* ChromeBluetoothDevice */ | 240 const JavaParamRef<jobject>& /* ChromeBluetoothDevice */ |
| 240 chrome_bluetooth_device) { | 241 chrome_bluetooth_device) { |
| 241 std::string instanceIdString = | 242 std::string instanceIdString = |
| 242 base::android::ConvertJavaStringToUTF8(env, instanceId); | 243 base::android::ConvertJavaStringToUTF8(env, instanceId); |
| 243 | 244 |
| 244 DCHECK(descriptors_.find(instanceIdString) == descriptors_.end()); | 245 DCHECK(!base::ContainsKey(descriptors_, instanceIdString)); |
| 245 | 246 |
| 246 descriptors_[instanceIdString] = BluetoothRemoteGattDescriptorAndroid::Create( | 247 descriptors_[instanceIdString] = BluetoothRemoteGattDescriptorAndroid::Create( |
| 247 instanceIdString, bluetooth_gatt_descriptor_wrapper, | 248 instanceIdString, bluetooth_gatt_descriptor_wrapper, |
| 248 chrome_bluetooth_device); | 249 chrome_bluetooth_device); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void BluetoothRemoteGattCharacteristicAndroid::SubscribeToNotifications( | 252 void BluetoothRemoteGattCharacteristicAndroid::SubscribeToNotifications( |
| 252 BluetoothRemoteGattDescriptor* ccc_descriptor, | 253 BluetoothRemoteGattDescriptor* ccc_descriptor, |
| 253 const base::Closure& callback, | 254 const base::Closure& callback, |
| 254 const ErrorCallback& error_callback) { | 255 const ErrorCallback& error_callback) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() | 299 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() |
| 299 const { | 300 const { |
| 300 if (!descriptors_.empty()) | 301 if (!descriptors_.empty()) |
| 301 return; | 302 return; |
| 302 | 303 |
| 303 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( | 304 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( |
| 304 AttachCurrentThread(), j_characteristic_); | 305 AttachCurrentThread(), j_characteristic_); |
| 305 } | 306 } |
| 306 | 307 |
| 307 } // namespace device | 308 } // namespace device |
| OLD | NEW |