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_device_android.h" | 5 #include "device/bluetooth/bluetooth_device_android.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 | 239 |
240 void BluetoothDeviceAndroid::CreateGattRemoteService( | 240 void BluetoothDeviceAndroid::CreateGattRemoteService( |
241 JNIEnv* env, | 241 JNIEnv* env, |
242 const JavaParamRef<jobject>& caller, | 242 const JavaParamRef<jobject>& caller, |
243 const JavaParamRef<jstring>& instance_id, | 243 const JavaParamRef<jstring>& instance_id, |
244 const JavaParamRef<jobject>& | 244 const JavaParamRef<jobject>& |
245 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper | 245 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper |
246 std::string instance_id_string = | 246 std::string instance_id_string = |
247 base::android::ConvertJavaStringToUTF8(env, instance_id); | 247 base::android::ConvertJavaStringToUTF8(env, instance_id); |
248 | 248 |
249 if (gatt_services_.contains(instance_id_string)) | 249 if (gatt_services_.find(instance_id_string) != gatt_services_.end()) |
Reilly Grant (use Gerrit)
2016/12/28 22:48:01
if (base::ContainsKey(gatt_services_, instance_id_
Avi (use Gerrit)
2017/01/02 19:42:26
Done.
| |
250 return; | 250 return; |
251 | 251 |
252 BluetoothDevice::GattServiceMap::iterator service_iterator = | 252 std::unique_ptr<BluetoothRemoteGattServiceAndroid> service = |
253 gatt_services_.set( | 253 BluetoothRemoteGattServiceAndroid::Create(GetAndroidAdapter(), this, |
254 instance_id_string, | 254 bluetooth_gatt_service_wrapper, |
255 BluetoothRemoteGattServiceAndroid::Create( | 255 instance_id_string, j_device_); |
256 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, | 256 BluetoothRemoteGattServiceAndroid* service_ptr = service.get(); |
257 instance_id_string, j_device_)); | 257 gatt_services_[instance_id_string] = std::move(service); |
258 | 258 |
259 adapter_->NotifyGattServiceAdded(service_iterator->second); | 259 adapter_->NotifyGattServiceAdded(service_ptr); |
260 } | 260 } |
261 | 261 |
262 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) | 262 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) |
263 : BluetoothDevice(adapter) {} | 263 : BluetoothDevice(adapter) {} |
264 | 264 |
265 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 265 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
266 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 266 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
267 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); | 267 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); |
268 } | 268 } |
269 | 269 |
270 void BluetoothDeviceAndroid::DisconnectGatt() { | 270 void BluetoothDeviceAndroid::DisconnectGatt() { |
271 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); | 271 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); |
272 } | 272 } |
273 | 273 |
274 } // namespace device | 274 } // namespace device |
OLD | NEW |