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

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

Issue 1572873002: bluetooth: android: Code cleanup fixing comments, typos, simplified names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 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 scoped_ptr<BluetoothRemoteGattServiceAndroid> 19 scoped_ptr<BluetoothRemoteGattServiceAndroid>
20 BluetoothRemoteGattServiceAndroid::Create( 20 BluetoothRemoteGattServiceAndroid::Create(
21 BluetoothAdapterAndroid* adapter, 21 BluetoothAdapterAndroid* adapter,
22 BluetoothDeviceAndroid* device, 22 BluetoothDeviceAndroid* device,
23 jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper, 23 jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper,
24 const std::string& instanceId, 24 const std::string& instance_id,
25 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device) { 25 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device) {
26 scoped_ptr<BluetoothRemoteGattServiceAndroid> service( 26 scoped_ptr<BluetoothRemoteGattServiceAndroid> service(
27 new BluetoothRemoteGattServiceAndroid(adapter, device, instanceId)); 27 new BluetoothRemoteGattServiceAndroid(adapter, device, instance_id));
28 28
29 JNIEnv* env = AttachCurrentThread(); 29 JNIEnv* env = AttachCurrentThread();
30 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create( 30 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create(
31 env, reinterpret_cast<intptr_t>(service.get()), 31 env, reinterpret_cast<intptr_t>(service.get()),
32 bluetooth_gatt_service_wrapper, 32 bluetooth_gatt_service_wrapper,
33 base::android::ConvertUTF8ToJavaString(env, instanceId).obj(), 33 base::android::ConvertUTF8ToJavaString(env, instance_id).obj(),
34 chrome_bluetooth_device)); 34 chrome_bluetooth_device));
35 35
36 return service; 36 return service;
37 } 37 }
38 38
39 BluetoothRemoteGattServiceAndroid::~BluetoothRemoteGattServiceAndroid() { 39 BluetoothRemoteGattServiceAndroid::~BluetoothRemoteGattServiceAndroid() {
40 Java_ChromeBluetoothRemoteGattService_onBluetoothRemoteGattServiceAndroidDestr uction( 40 Java_ChromeBluetoothRemoteGattService_onBluetoothRemoteGattServiceAndroidDestr uction(
41 AttachCurrentThread(), j_service_.obj()); 41 AttachCurrentThread(), j_service_.obj());
42 } 42 }
43 43
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 case GATT_ERROR_NOT_PAIRED: 100 case GATT_ERROR_NOT_PAIRED:
101 return 0x00000101; // GATT_FAILURE. No good match. 101 return 0x00000101; // GATT_FAILURE. No good match.
102 case GATT_ERROR_NOT_SUPPORTED: 102 case GATT_ERROR_NOT_SUPPORTED:
103 return 0x00000006; // GATT_REQUEST_NOT_SUPPORTED 103 return 0x00000006; // GATT_REQUEST_NOT_SUPPORTED
104 } 104 }
105 VLOG(1) << "Unhandled error_code: " << error_code; 105 VLOG(1) << "Unhandled error_code: " << error_code;
106 return 0x00000101; // GATT_FAILURE. No good match. 106 return 0x00000101; // GATT_FAILURE. No good match.
107 } 107 }
108 108
109 std::string BluetoothRemoteGattServiceAndroid::GetIdentifier() const { 109 std::string BluetoothRemoteGattServiceAndroid::GetIdentifier() const {
110 return instanceId_; 110 return instance_id_;
111 } 111 }
112 112
113 device::BluetoothUUID BluetoothRemoteGattServiceAndroid::GetUUID() const { 113 device::BluetoothUUID BluetoothRemoteGattServiceAndroid::GetUUID() const {
114 return device::BluetoothUUID( 114 return device::BluetoothUUID(
115 ConvertJavaStringToUTF8(Java_ChromeBluetoothRemoteGattService_getUUID( 115 ConvertJavaStringToUTF8(Java_ChromeBluetoothRemoteGattService_getUUID(
116 AttachCurrentThread(), j_service_.obj()))); 116 AttachCurrentThread(), j_service_.obj())));
117 } 117 }
118 118
119 bool BluetoothRemoteGattServiceAndroid::IsLocal() const { 119 bool BluetoothRemoteGattServiceAndroid::IsLocal() const {
120 return false; 120 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 void BluetoothRemoteGattServiceAndroid::Unregister( 173 void BluetoothRemoteGattServiceAndroid::Unregister(
174 const base::Closure& callback, 174 const base::Closure& callback,
175 const ErrorCallback& error_callback) { 175 const ErrorCallback& error_callback) {
176 error_callback.Run(); 176 error_callback.Run();
177 } 177 }
178 178
179 void BluetoothRemoteGattServiceAndroid::CreateGattRemoteCharacteristic( 179 void BluetoothRemoteGattServiceAndroid::CreateGattRemoteCharacteristic(
180 JNIEnv* env, 180 JNIEnv* env,
181 const JavaParamRef<jobject>& caller, 181 const JavaParamRef<jobject>& caller,
182 const JavaParamRef<jstring>& instanceId, 182 const JavaParamRef<jstring>& instance_id,
183 const JavaParamRef<jobject>& /* BluetoothGattCharacteristicWrapper */ 183 const JavaParamRef<jobject>& /* BluetoothGattCharacteristicWrapper */
184 bluetooth_gatt_characteristic_wrapper, 184 bluetooth_gatt_characteristic_wrapper,
185 const JavaParamRef< 185 const JavaParamRef<
186 jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device) { 186 jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device) {
187 std::string instanceIdString = 187 std::string instance_id_string =
188 base::android::ConvertJavaStringToUTF8(env, instanceId); 188 base::android::ConvertJavaStringToUTF8(env, instance_id);
189 189
190 DCHECK(!characteristics_.contains(instanceIdString)); 190 DCHECK(!characteristics_.contains(instance_id_string));
191 191
192 characteristics_.set( 192 characteristics_.set(
193 instanceIdString, 193 instance_id_string,
194 BluetoothRemoteGattCharacteristicAndroid::Create( 194 BluetoothRemoteGattCharacteristicAndroid::Create(
195 instanceIdString, bluetooth_gatt_characteristic_wrapper, 195 instance_id_string, bluetooth_gatt_characteristic_wrapper,
196 chrome_bluetooth_device)); 196 chrome_bluetooth_device));
197 } 197 }
198 198
199 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid( 199 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid(
200 BluetoothAdapterAndroid* adapter, 200 BluetoothAdapterAndroid* adapter,
201 BluetoothDeviceAndroid* device, 201 BluetoothDeviceAndroid* device,
202 const std::string& instanceId) 202 const std::string& instance_id)
203 : adapter_(adapter), device_(device), instanceId_(instanceId) {} 203 : adapter_(adapter), device_(device), instance_id_(instance_id) {}
204 204
205 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const { 205 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const {
206 if (!characteristics_.empty()) 206 if (!characteristics_.empty())
207 return; 207 return;
208 208
209 // Java call 209 // Java call
210 Java_ChromeBluetoothRemoteGattService_ensureCharacteristicsCreated( 210 Java_ChromeBluetoothRemoteGattService_ensureCharacteristicsCreated(
211 AttachCurrentThread(), j_service_.obj()); 211 AttachCurrentThread(), j_service_.obj());
212 } 212 }
213 213
214 } // namespace device 214 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698