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

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: address ortuno 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 =
240 BluetoothRemoteGattServiceAndroid::Create( 240 gatt_services_.set(instanceIdString,
241 GetAdapter(), this, bluetooth_gatt_service_wrapper, instanceIdString); 241 BluetoothRemoteGattServiceAndroid::Create(
242 242 GetAdapter(), this, bluetooth_gatt_service_wrapper,
243 gatt_services_.set(instanceIdString, 243 instanceIdString));
244 make_scoped_ptr<BluetoothGattService>(service));
245 244
246 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), 245 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(),
247 GattServiceAdded(adapter_, this, service)); 246 GattServiceAdded(adapter_, this, service_iterator->second));
248 } 247 }
249 248
250 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 249 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
251 : BluetoothDevice(adapter) {} 250 : BluetoothDevice(adapter) {}
252 251
253 std::string BluetoothDeviceAndroid::GetDeviceName() const { 252 std::string BluetoothDeviceAndroid::GetDeviceName() const {
254 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( 253 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
255 AttachCurrentThread(), j_device_.obj())); 254 AttachCurrentThread(), j_device_.obj()));
256 } 255 }
257 256
258 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 257 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
259 Java_ChromeBluetoothDevice_createGattConnectionImpl( 258 Java_ChromeBluetoothDevice_createGattConnectionImpl(
260 AttachCurrentThread(), j_device_.obj(), 259 AttachCurrentThread(), j_device_.obj(),
261 base::android::GetApplicationContext()); 260 base::android::GetApplicationContext());
262 } 261 }
263 262
264 void BluetoothDeviceAndroid::DisconnectGatt() { 263 void BluetoothDeviceAndroid::DisconnectGatt() {
265 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 264 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
266 j_device_.obj()); 265 j_device_.obj());
267 } 266 }
268 267
269 } // namespace device 268 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698