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

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

Issue 1411183003: bluetooth: android: Clean up BluetoothRemoteGattServiceAndroid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-getid-
Patch Set: Created 5 years, 1 month 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/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 const jstring& instanceId, 229 const jstring& instanceId,
230 jobject bluetooth_gatt_service_wrapper // Java Type: 230 jobject bluetooth_gatt_service_wrapper // Java Type:
231 // BluetoothGattServiceWrapper 231 // BluetoothGattServiceWrapper
232 ) { 232 ) {
233 std::string instanceIdString = 233 std::string instanceIdString =
234 base::android::ConvertJavaStringToUTF8(env, instanceId); 234 base::android::ConvertJavaStringToUTF8(env, instanceId);
235 235
236 if (gatt_services_.contains(instanceIdString)) 236 if (gatt_services_.contains(instanceIdString))
237 return; 237 return;
238 238
239 BluetoothRemoteGattServiceAndroid* service = 239 BluetoothDevice::GattServiceMap::iterator service_iterator =
ortuno 2015/10/26 21:36:26 nit: can you use auto?
scheib 2015/10/26 21:55:47 This is a grey area. Style guide recommends being
ortuno 2015/10/26 22:23:34 hmm not sure how BluetoothDevice::GattServiceMap m
240 BluetoothRemoteGattServiceAndroid::Create( 240 gatt_services_.set(
241 GetAdapter(), this, bluetooth_gatt_service_wrapper, instanceIdString); 241 instanceIdString,
242 242 make_scoped_ptr<BluetoothRemoteGattServiceAndroid>(
243 gatt_services_.set(instanceIdString, 243 BluetoothRemoteGattServiceAndroid::Create(
244 make_scoped_ptr<BluetoothGattService>(service)); 244 GetAdapter(), this, bluetooth_gatt_service_wrapper,
245 instanceIdString)));
245 246
246 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), 247 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(),
247 GattServiceAdded(adapter_, this, service)); 248 GattServiceAdded(adapter_, this, service_iterator->second));
248 } 249 }
249 250
250 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 251 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
251 : BluetoothDevice(adapter) {} 252 : BluetoothDevice(adapter) {}
252 253
253 std::string BluetoothDeviceAndroid::GetDeviceName() const { 254 std::string BluetoothDeviceAndroid::GetDeviceName() const {
254 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( 255 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
255 AttachCurrentThread(), j_device_.obj())); 256 AttachCurrentThread(), j_device_.obj()));
256 } 257 }
257 258
258 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 259 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
259 Java_ChromeBluetoothDevice_createGattConnectionImpl( 260 Java_ChromeBluetoothDevice_createGattConnectionImpl(
260 AttachCurrentThread(), j_device_.obj(), 261 AttachCurrentThread(), j_device_.obj(),
261 base::android::GetApplicationContext()); 262 base::android::GetApplicationContext());
262 } 263 }
263 264
264 void BluetoothDeviceAndroid::DisconnectGatt() { 265 void BluetoothDeviceAndroid::DisconnectGatt() {
265 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 266 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
266 j_device_.obj()); 267 j_device_.obj());
267 } 268 }
268 269
269 } // namespace device 270 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698