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

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: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/21 22:25:13 if (base::ContainsKey(gatt_services_, instance_id_
dougt 2016/12/22 01:18:02 Done.
250 return; 250 return;
251 251
252 BluetoothDevice::GattServiceMap::iterator service_iterator = 252 auto service = BluetoothRemoteGattServiceAndroid::Create(
253 gatt_services_.set( 253 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper,
254 instance_id_string, 254 instance_id_string, j_device_);
255 BluetoothRemoteGattServiceAndroid::Create(
256 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper,
257 instance_id_string, j_device_));
258 255
259 adapter_->NotifyGattServiceAdded(service_iterator->second); 256 auto insertion = gatt_services_.insert(
257 std::make_pair(instance_id_string, std::move(service)));
258 if (insertion.second == false) {
Reilly Grant (use Gerrit) 2016/12/21 22:25:14 insertion.second will always be true because we ch
dougt 2016/12/22 01:18:02 Done.
259 return;
260 }
261 adapter_->NotifyGattServiceAdded(insertion.first->second.get());
260 } 262 }
261 263
262 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 264 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
263 : BluetoothDevice(adapter) {} 265 : BluetoothDevice(adapter) {}
264 266
265 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 267 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
266 Java_ChromeBluetoothDevice_createGattConnectionImpl( 268 Java_ChromeBluetoothDevice_createGattConnectionImpl(
267 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); 269 AttachCurrentThread(), j_device_, base::android::GetApplicationContext());
268 } 270 }
269 271
270 void BluetoothDeviceAndroid::DisconnectGatt() { 272 void BluetoothDeviceAndroid::DisconnectGatt() {
271 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); 273 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_);
272 } 274 }
273 275
274 } // namespace device 276 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698