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

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

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Mac bustage Created 3 years, 12 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_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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
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 if (base::ContainsKey(gatt_services_, instance_id_string))
249 if (gatt_services_.contains(instance_id_string))
250 return; 249 return;
251 250
252 BluetoothDevice::GattServiceMap::iterator service_iterator = 251 auto service = BluetoothRemoteGattServiceAndroid::Create(
253 gatt_services_.set( 252 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper,
254 instance_id_string, 253 instance_id_string, j_device_);
255 BluetoothRemoteGattServiceAndroid::Create( 254 auto insertion = gatt_services_.insert(
256 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, 255 std::make_pair(instance_id_string, std::move(service)));
257 instance_id_string, j_device_)); 256 adapter_->NotifyGattServiceAdded(insertion.first->second.get());
258
259 adapter_->NotifyGattServiceAdded(service_iterator->second);
260 } 257 }
261 258
262 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 259 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
263 : BluetoothDevice(adapter) {} 260 : BluetoothDevice(adapter) {}
264 261
265 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 262 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
266 Java_ChromeBluetoothDevice_createGattConnectionImpl( 263 Java_ChromeBluetoothDevice_createGattConnectionImpl(
267 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); 264 AttachCurrentThread(), j_device_, base::android::GetApplicationContext());
268 } 265 }
269 266
270 void BluetoothDeviceAndroid::DisconnectGatt() { 267 void BluetoothDeviceAndroid::DisconnectGatt() {
271 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); 268 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_);
272 } 269 }
273 270
274 } // namespace device 271 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698