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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_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 | « device/bluetooth/bluetooth_remote_gatt_service_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_remote_gatt_service_android.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "device/bluetooth/bluetooth_adapter_android.h" 9 #include "device/bluetooth/bluetooth_adapter_android.h"
10 #include "device/bluetooth/bluetooth_device_android.h" 10 #include "device/bluetooth/bluetooth_device_android.h"
11 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" 11 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h"
12 #include "jni/ChromeBluetoothRemoteGattService_jni.h" 12 #include "jni/ChromeBluetoothRemoteGattService_jni.h"
13 13
14 using base::android::AttachCurrentThread; 14 using base::android::AttachCurrentThread;
15 15
16 namespace device { 16 namespace device {
17 17
18 // static 18 // static
19 BluetoothRemoteGattServiceAndroid* BluetoothRemoteGattServiceAndroid::Create( 19 scoped_ptr<BluetoothRemoteGattServiceAndroid>
20 BluetoothRemoteGattServiceAndroid::Create(
20 BluetoothAdapterAndroid* adapter, 21 BluetoothAdapterAndroid* adapter,
21 BluetoothDeviceAndroid* device, 22 BluetoothDeviceAndroid* device,
22 jobject bluetooth_remote_gatt_service_wrapper, 23 jobject bluetooth_gatt_service_wrapper,
23 const std::string& instanceId) { 24 const std::string& instanceId) {
24 BluetoothRemoteGattServiceAndroid* service = 25 scoped_ptr<BluetoothRemoteGattServiceAndroid> service(
25 new BluetoothRemoteGattServiceAndroid(adapter, device, instanceId); 26 new BluetoothRemoteGattServiceAndroid(adapter, device, instanceId));
26 27
27 JNIEnv* env = base::android::AttachCurrentThread(); 28 JNIEnv* env = AttachCurrentThread();
28 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create( 29 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create(
29 env, reinterpret_cast<intptr_t>(service), 30 env, reinterpret_cast<intptr_t>(service.get()),
30 bluetooth_remote_gatt_service_wrapper, 31 bluetooth_gatt_service_wrapper,
31 base::android::ConvertUTF8ToJavaString(env, instanceId).obj())); 32 base::android::ConvertUTF8ToJavaString(env, instanceId).obj()));
32 33
33 return service; 34 return service;
34 } 35 }
35 36
37 BluetoothRemoteGattServiceAndroid::~BluetoothRemoteGattServiceAndroid() {
38 Java_ChromeBluetoothRemoteGattService_onBluetoothRemoteGattServiceAndroidDestr uction(
39 AttachCurrentThread(), j_service_.obj());
40 }
41
36 // static 42 // static
37 bool BluetoothRemoteGattServiceAndroid::RegisterJNI(JNIEnv* env) { 43 bool BluetoothRemoteGattServiceAndroid::RegisterJNI(JNIEnv* env) {
38 return RegisterNativesImpl( 44 return RegisterNativesImpl(
39 env); // Generated in ChromeBluetoothRemoteGattService_jni.h 45 env); // Generated in ChromeBluetoothRemoteGattService_jni.h
40 } 46 }
41 47
42 base::android::ScopedJavaLocalRef<jobject> 48 base::android::ScopedJavaLocalRef<jobject>
43 BluetoothRemoteGattServiceAndroid::GetJavaObject() { 49 BluetoothRemoteGattServiceAndroid::GetJavaObject() {
44 return base::android::ScopedJavaLocalRef<jobject>(j_service_); 50 return base::android::ScopedJavaLocalRef<jobject>(j_service_);
45 } 51 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 instanceIdString, 135 instanceIdString,
130 BluetoothRemoteGattCharacteristicAndroid::Create(instanceIdString)); 136 BluetoothRemoteGattCharacteristicAndroid::Create(instanceIdString));
131 } 137 }
132 138
133 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid( 139 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid(
134 BluetoothAdapterAndroid* adapter, 140 BluetoothAdapterAndroid* adapter,
135 BluetoothDeviceAndroid* device, 141 BluetoothDeviceAndroid* device,
136 const std::string& instanceId) 142 const std::string& instanceId)
137 : adapter_(adapter), device_(device), instanceId_(instanceId) {} 143 : adapter_(adapter), device_(device), instanceId_(instanceId) {}
138 144
139 BluetoothRemoteGattServiceAndroid::~BluetoothRemoteGattServiceAndroid() {
140 Java_ChromeBluetoothRemoteGattService_onBluetoothRemoteGattServiceAndroidDestr uction(
141 AttachCurrentThread(), j_service_.obj());
142 }
143
144 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const { 145 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const {
145 if (!characteristics_.empty()) 146 if (!characteristics_.empty())
146 return; 147 return;
147 148
148 // Java call 149 // Java call
149 Java_ChromeBluetoothRemoteGattService_ensureCharacteristicsCreated( 150 Java_ChromeBluetoothRemoteGattService_ensureCharacteristicsCreated(
150 AttachCurrentThread(), j_service_.obj()); 151 AttachCurrentThread(), j_service_.obj());
151 } 152 }
152 153
153 } // namespace device 154 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698