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

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

Issue 1412963004: bluetooth: android: Implement Characteristic GetIdentifier, fix Service IDs too. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 // The ChromeBluetoothRemoteGattService instance will hold a Java reference 33 // The ChromeBluetoothRemoteGattService instance will hold a Java reference
34 // to |bluetooth_remote_gatt_service_wrapper|. 34 // to |bluetooth_remote_gatt_service_wrapper|.
35 // 35 //
36 // TODO(scheib): Return a scoped_ptr<>, but then device will need to handle 36 // TODO(scheib): Return a scoped_ptr<>, but then device will need to handle
37 // this correctly. http://crbug.com/506416 37 // this correctly. http://crbug.com/506416
38 static BluetoothRemoteGattServiceAndroid* Create( 38 static BluetoothRemoteGattServiceAndroid* Create(
39 BluetoothAdapterAndroid* adapter, 39 BluetoothAdapterAndroid* adapter,
40 BluetoothDeviceAndroid* device, 40 BluetoothDeviceAndroid* device,
41 jobject bluetooth_remote_gatt_service_wrapper, // Java Type: 41 jobject bluetooth_remote_gatt_service_wrapper, // Java Type:
42 // BluetoothRemoteGattServiceWrapper 42 // BluetoothRemoteGattServiceWrapper
43 std::string instanceId); 43 const std::string& instanceId);
44 44
45 // Register C++ methods exposed to Java using JNI. 45 // Register C++ methods exposed to Java using JNI.
46 static bool RegisterJNI(JNIEnv* env); 46 static bool RegisterJNI(JNIEnv* env);
47 47
48 // Returns the associated ChromeBluetoothRemoteGattService Java object. 48 // Returns the associated ChromeBluetoothRemoteGattService Java object.
49 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 49 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
50 50
51 // device::BluetoothGattService overrides. 51 // device::BluetoothGattService overrides.
52 std::string GetIdentifier() const override; 52 std::string GetIdentifier() const override;
53 device::BluetoothUUID GetUUID() const override; 53 device::BluetoothUUID GetUUID() const override;
(...skipping 21 matching lines...) Expand all
75 jobject caller, 75 jobject caller,
76 const jstring& instanceId, 76 const jstring& instanceId,
77 jobject /* BluetoothGattCharacteristicWrapper */ 77 jobject /* BluetoothGattCharacteristicWrapper */
78 bluetooth_gatt_characteristic_wrapper); 78 bluetooth_gatt_characteristic_wrapper);
79 79
80 private: 80 private:
81 friend class BluetoothDeviceAndroid; 81 friend class BluetoothDeviceAndroid;
82 82
83 BluetoothRemoteGattServiceAndroid(BluetoothAdapterAndroid* adapter, 83 BluetoothRemoteGattServiceAndroid(BluetoothAdapterAndroid* adapter,
84 BluetoothDeviceAndroid* device, 84 BluetoothDeviceAndroid* device,
85 std::string instanceId); 85 const std::string& instanceId);
86 ~BluetoothRemoteGattServiceAndroid() override; 86 ~BluetoothRemoteGattServiceAndroid() override;
87 87
88 // Populates |characteristics_| from Java objects if necessary. 88 // Populates |characteristics_| from Java objects if necessary.
89 void EnsureCharacteristicsCreated() const; 89 void EnsureCharacteristicsCreated() const;
90 90
91 // Java object org.chromium.device.bluetooth.ChromeBluetoothRemoteGattService. 91 // Java object org.chromium.device.bluetooth.ChromeBluetoothRemoteGattService.
92 base::android::ScopedJavaGlobalRef<jobject> j_service_; 92 base::android::ScopedJavaGlobalRef<jobject> j_service_;
93 93
94 // The adapter associated with this service. It's ok to store a raw pointer 94 // The adapter associated with this service. It's ok to store a raw pointer
95 // here since |adapter_| indirectly owns this instance. 95 // here since |adapter_| indirectly owns this instance.
96 BluetoothAdapterAndroid* adapter_; 96 BluetoothAdapterAndroid* adapter_;
97 97
98 // The device this GATT service belongs to. It's ok to store a raw pointer 98 // The device this GATT service belongs to. It's ok to store a raw pointer
99 // here since |device_| owns this instance. 99 // here since |device_| owns this instance.
100 BluetoothDeviceAndroid* device_; 100 BluetoothDeviceAndroid* device_;
101 101
102 // Instance ID, cached from Android object. 102 // Adapter unique instance ID.
103 std::string instanceId_; 103 std::string instanceId_;
104 104
105 // Map of characteristics, keyed by characteristic identifier. 105 // Map of characteristics, keyed by characteristic identifier.
106 base::ScopedPtrHashMap<std::string, 106 base::ScopedPtrHashMap<std::string,
107 scoped_ptr<BluetoothRemoteGattCharacteristicAndroid>> 107 scoped_ptr<BluetoothRemoteGattCharacteristicAndroid>>
108 characteristics_; 108 characteristics_;
109 109
110 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid); 110 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid);
111 }; 111 };
112 112
113 } // namespace device 113 } // namespace device
114 114
115 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ 115 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698