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

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

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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 <memory> 10 #include <memory>
11 11
12 #include "base/android/jni_android.h" 12 #include "base/android/jni_android.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/scoped_ptr_hash_map.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 15 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
16 16
17 namespace device { 17 namespace device {
18 18
19 class BluetoothAdapterAndroid; 19 class BluetoothAdapterAndroid;
20 class BluetoothRemoteGattDescriptorAndroid; 20 class BluetoothRemoteGattDescriptorAndroid;
21 class BluetoothRemoteGattServiceAndroid; 21 class BluetoothRemoteGattServiceAndroid;
22 22
23 // BluetoothRemoteGattCharacteristicAndroid along with its owned Java class 23 // BluetoothRemoteGattCharacteristicAndroid along with its owned Java class
24 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic 24 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic
25 // implement BluetootGattCharacteristic. 25 // implement BluetootGattCharacteristic.
26 // 26 //
27 // TODO(crbug.com/551634): When notifications are enabled characteristic updates 27 // TODO(crbug.com/551634): When notifications are enabled characteristic updates
28 // should call observers' GattCharacteristicValueChanged. 28 // should call observers' GattCharacteristicValueChanged.
29 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid 29 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
30 : public BluetoothGattCharacteristic { 30 : public BluetoothRemoteGattCharacteristic {
31 public: 31 public:
32 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated 32 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated
33 // Java 33 // Java
34 // ChromeBluetoothRemoteGattCharacteristic using the provided 34 // ChromeBluetoothRemoteGattCharacteristic using the provided
35 // |bluetooth_gatt_characteristic_wrapper|. 35 // |bluetooth_gatt_characteristic_wrapper|.
36 // 36 //
37 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java 37 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java
38 // reference 38 // reference
39 // to |bluetooth_gatt_characteristic_wrapper|. 39 // to |bluetooth_gatt_characteristic_wrapper|.
40 static std::unique_ptr<BluetoothRemoteGattCharacteristicAndroid> Create( 40 static std::unique_ptr<BluetoothRemoteGattCharacteristicAndroid> Create(
41 BluetoothAdapterAndroid* adapter, 41 BluetoothAdapterAndroid* adapter,
42 BluetoothRemoteGattServiceAndroid* service, 42 BluetoothRemoteGattServiceAndroid* service,
43 const std::string& instance_id, 43 const std::string& instance_id,
44 jobject /* BluetoothGattCharacteristicWrapper */ 44 jobject /* BluetoothGattCharacteristicWrapper */
45 bluetooth_gatt_characteristic_wrapper, 45 bluetooth_gatt_characteristic_wrapper,
46 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device); 46 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device);
47 47
48 ~BluetoothRemoteGattCharacteristicAndroid() override; 48 ~BluetoothRemoteGattCharacteristicAndroid() override;
49 49
50 // Register C++ methods exposed to Java using JNI. 50 // Register C++ methods exposed to Java using JNI.
51 static bool RegisterJNI(JNIEnv* env); 51 static bool RegisterJNI(JNIEnv* env);
52 52
53 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object. 53 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object.
54 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 54 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
55 55
56 // BluetoothGattCharacteristic interface: 56 // BluetoothRemoteGattCharacteristic interface:
57 std::string GetIdentifier() const override; 57 std::string GetIdentifier() const override;
58 BluetoothUUID GetUUID() const override; 58 BluetoothUUID GetUUID() const override;
59 bool IsLocal() const override; 59 bool IsLocal() const override;
60 const std::vector<uint8_t>& GetValue() const override; 60 const std::vector<uint8_t>& GetValue() const override;
61 BluetoothGattService* GetService() const override; 61 BluetoothRemoteGattService* GetService() const override;
62 Properties GetProperties() const override; 62 Properties GetProperties() const override;
63 Permissions GetPermissions() const override; 63 Permissions GetPermissions() const override;
64 bool IsNotifying() const override; 64 bool IsNotifying() const override;
65 std::vector<BluetoothGattDescriptor*> GetDescriptors() const override; 65 std::vector<BluetoothRemoteGattDescriptor*> GetDescriptors() const override;
66 BluetoothGattDescriptor* GetDescriptor( 66 BluetoothRemoteGattDescriptor* GetDescriptor(
67 const std::string& identifier) const override; 67 const std::string& identifier) const override;
68 bool AddDescriptor(BluetoothGattDescriptor* descriptor) override; 68 bool AddDescriptor(BluetoothRemoteGattDescriptor* descriptor) override;
69 bool UpdateValue(const std::vector<uint8_t>& value) override; 69 bool UpdateValue(const std::vector<uint8_t>& value) override;
70 void StartNotifySession(const NotifySessionCallback& callback, 70 void StartNotifySession(const NotifySessionCallback& callback,
71 const ErrorCallback& error_callback) override; 71 const ErrorCallback& error_callback) override;
72 void ReadRemoteCharacteristic(const ValueCallback& callback, 72 void ReadRemoteCharacteristic(const ValueCallback& callback,
73 const ErrorCallback& error_callback) override; 73 const ErrorCallback& error_callback) override;
74 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, 74 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
75 const base::Closure& callback, 75 const base::Closure& callback,
76 const ErrorCallback& error_callback) override; 76 const ErrorCallback& error_callback) override;
77 77
78 // Called when StartNotifySession operation succeeds. 78 // Called when StartNotifySession operation succeeds.
79 void OnStartNotifySessionSuccess(); 79 void OnStartNotifySessionSuccess();
80 80
81 // Called when StartNotifySession operation fails. 81 // Called when StartNotifySession operation fails.
82 void OnStartNotifySessionError(BluetoothGattService::GattErrorCode error); 82 void OnStartNotifySessionError(
83 BluetoothRemoteGattService::GattErrorCode error);
83 84
84 // Called when value changed event occurs. 85 // Called when value changed event occurs.
85 void OnChanged(JNIEnv* env, 86 void OnChanged(JNIEnv* env,
86 const base::android::JavaParamRef<jobject>& jcaller, 87 const base::android::JavaParamRef<jobject>& jcaller,
87 const base::android::JavaParamRef<jbyteArray>& value); 88 const base::android::JavaParamRef<jbyteArray>& value);
88 89
89 // Called when Read operation completes. 90 // Called when Read operation completes.
90 void OnRead(JNIEnv* env, 91 void OnRead(JNIEnv* env,
91 const base::android::JavaParamRef<jobject>& jcaller, 92 const base::android::JavaParamRef<jobject>& jcaller,
92 int32_t status, 93 int32_t status,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 base::ScopedPtrHashMap<std::string, 153 base::ScopedPtrHashMap<std::string,
153 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid>> 154 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid>>
154 descriptors_; 155 descriptors_;
155 156
156 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); 157 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid);
157 }; 158 };
158 159
159 } // namespace device 160 } // namespace device
160 161
161 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ 162 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698