| OLD | NEW |
| 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_CHARACTERISTIC_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated | 25 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated |
| 26 // Java | 26 // Java |
| 27 // ChromeBluetoothRemoteGattCharacteristic using the provided | 27 // ChromeBluetoothRemoteGattCharacteristic using the provided |
| 28 // |bluetooth_gatt_characteristic_wrapper|. | 28 // |bluetooth_gatt_characteristic_wrapper|. |
| 29 // | 29 // |
| 30 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java | 30 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java |
| 31 // reference | 31 // reference |
| 32 // to |bluetooth_gatt_characteristic_wrapper|. | 32 // to |bluetooth_gatt_characteristic_wrapper|. |
| 33 static scoped_ptr<BluetoothRemoteGattCharacteristicAndroid> Create( | 33 static scoped_ptr<BluetoothRemoteGattCharacteristicAndroid> Create( |
| 34 const std::string& instanceId, | 34 const std::string& instance_id, |
| 35 jobject /* BluetoothGattCharacteristicWrapper */ | 35 jobject /* BluetoothGattCharacteristicWrapper */ |
| 36 bluetooth_gatt_characteristic_wrapper, | 36 bluetooth_gatt_characteristic_wrapper, |
| 37 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device); | 37 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device); |
| 38 | 38 |
| 39 ~BluetoothRemoteGattCharacteristicAndroid() override; | 39 ~BluetoothRemoteGattCharacteristicAndroid() override; |
| 40 | 40 |
| 41 // Register C++ methods exposed to Java using JNI. | 41 // Register C++ methods exposed to Java using JNI. |
| 42 static bool RegisterJNI(JNIEnv* env); | 42 static bool RegisterJNI(JNIEnv* env); |
| 43 | 43 |
| 44 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object. | 44 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 71 const base::android::JavaParamRef<jobject>& jcaller, | 71 const base::android::JavaParamRef<jobject>& jcaller, |
| 72 int32_t status, | 72 int32_t status, |
| 73 const base::android::JavaParamRef<jbyteArray>& value); | 73 const base::android::JavaParamRef<jbyteArray>& value); |
| 74 | 74 |
| 75 // Callback after Write operation completes. | 75 // Callback after Write operation completes. |
| 76 void OnWrite(JNIEnv* env, | 76 void OnWrite(JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& jcaller, | 77 const base::android::JavaParamRef<jobject>& jcaller, |
| 78 int32_t status); | 78 int32_t status); |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 BluetoothRemoteGattCharacteristicAndroid(const std::string& instanceId); | 81 BluetoothRemoteGattCharacteristicAndroid(const std::string& instance_id); |
| 82 | 82 |
| 83 // Java object | 83 // Java object |
| 84 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. | 84 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. |
| 85 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; | 85 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; |
| 86 | 86 |
| 87 // Adapter unique instance ID. | 87 // Adapter unique instance ID. |
| 88 std::string instance_id_; | 88 std::string instance_id_; |
| 89 | 89 |
| 90 // ReadRemoteCharacteristic callbacks and pending state. | 90 // ReadRemoteCharacteristic callbacks and pending state. |
| 91 bool read_pending_ = false; | 91 bool read_pending_ = false; |
| 92 ValueCallback read_callback_; | 92 ValueCallback read_callback_; |
| 93 ErrorCallback read_error_callback_; | 93 ErrorCallback read_error_callback_; |
| 94 | 94 |
| 95 // WriteRemoteCharacteristic callbacks and pending state. | 95 // WriteRemoteCharacteristic callbacks and pending state. |
| 96 bool write_pending_ = false; | 96 bool write_pending_ = false; |
| 97 base::Closure write_callback_; | 97 base::Closure write_callback_; |
| 98 ErrorCallback write_error_callback_; | 98 ErrorCallback write_error_callback_; |
| 99 | 99 |
| 100 std::vector<uint8_t> value_; | 100 std::vector<uint8_t> value_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); | 102 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace device | 105 } // namespace device |
| 106 | 106 |
| 107 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ | 107 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
| OLD | NEW |