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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.h

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: Defer c++ pointer to a later patch. 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
index 8b94cb4bb3794290db768950808991def59da8c2..07522c2112d182cce60d613052dfa9d40e408009 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.h
@@ -8,11 +8,15 @@
#include <stdint.h>
#include "base/android/jni_android.h"
+#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "device/bluetooth/bluetooth_gatt_characteristic.h"
namespace device {
+class BluetoothAdapterAndroid;
+class BluetoothRemoteGattDescriptorAndroid;
+
// BluetoothRemoteGattCharacteristicAndroid along with its owned Java class
// org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic
// implement BluetootGattCharacteristic.
@@ -31,6 +35,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
// reference
// to |bluetooth_gatt_characteristic_wrapper|.
static scoped_ptr<BluetoothRemoteGattCharacteristicAndroid> Create(
+ BluetoothAdapterAndroid* adapter,
const std::string& instance_id,
jobject /* BluetoothGattCharacteristicWrapper */
bluetooth_gatt_characteristic_wrapper,
@@ -77,8 +82,29 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
const base::android::JavaParamRef<jobject>& jcaller,
int32_t status);
+ // Creates a Bluetooth GATT descriptor object and adds it to |descriptors_|
Jeffrey Yasskin 2016/01/12 21:53:54 Add a comma before 'DCHECKing'.
scheib 2016/01/12 23:16:56 Done.
+ // DCHECKing that it has not already been created.
+ void CreateGattRemoteDescriptor(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& caller,
+ const base::android::JavaParamRef<jstring>& instanceId,
+ const base::android::JavaParamRef<
+ jobject>& /* BluetoothGattDescriptorWrapper */
+ bluetooth_gatt_descriptor_wrapper,
+ const base::android::JavaParamRef<
+ jobject>& /* ChromeBluetoothCharacteristic */
+ chrome_bluetooth_characteristic);
+
private:
- BluetoothRemoteGattCharacteristicAndroid(const std::string& instance_id);
+ BluetoothRemoteGattCharacteristicAndroid(BluetoothAdapterAndroid* adapter,
+ const std::string& instance_id);
+
+ // Populates |descriptors_| from Java objects if necessary.
+ void EnsureDescriptorsCreated() const;
+
+ // The adapter associated with this service. It's ok to store a raw pointer
+ // here since |adapter_| indirectly owns this instance.
+ BluetoothAdapterAndroid* adapter_;
// Java object
// org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic.
@@ -99,6 +125,11 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
std::vector<uint8_t> value_;
+ // Map of descriptors, keyed by descriptor identifier.
+ base::ScopedPtrHashMap<std::string,
+ scoped_ptr<BluetoothRemoteGattDescriptorAndroid>>
+ descriptors_;
+
DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698