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

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

Issue 2241263005: Revert of Implement BluetoothGattNotifySession::Stop on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object. 54 // Returns the associated ChromeBluetoothRemoteGattCharacteristic Java object.
55 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 55 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
56 56
57 // BluetoothRemoteGattCharacteristic interface: 57 // BluetoothRemoteGattCharacteristic interface:
58 std::string GetIdentifier() const override; 58 std::string GetIdentifier() const override;
59 BluetoothUUID GetUUID() const override; 59 BluetoothUUID GetUUID() const override;
60 const std::vector<uint8_t>& GetValue() const override; 60 const std::vector<uint8_t>& GetValue() const override;
61 BluetoothRemoteGattService* 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 std::vector<BluetoothRemoteGattDescriptor*> GetDescriptors() const override; 65 std::vector<BluetoothRemoteGattDescriptor*> GetDescriptors() const override;
65 BluetoothRemoteGattDescriptor* GetDescriptor( 66 BluetoothRemoteGattDescriptor* GetDescriptor(
66 const std::string& identifier) const override; 67 const std::string& identifier) const override;
68 void StartNotifySession(const NotifySessionCallback& callback,
69 const ErrorCallback& error_callback) override;
67 void ReadRemoteCharacteristic(const ValueCallback& callback, 70 void ReadRemoteCharacteristic(const ValueCallback& callback,
68 const ErrorCallback& error_callback) override; 71 const ErrorCallback& error_callback) override;
69 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, 72 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
70 const base::Closure& callback, 73 const base::Closure& callback,
71 const ErrorCallback& error_callback) override; 74 const ErrorCallback& error_callback) override;
72 75
76 // Called when StartNotifySession operation succeeds.
77 void OnStartNotifySessionSuccess();
78
79 // Called when StartNotifySession operation fails.
80 void OnStartNotifySessionError(
81 BluetoothRemoteGattService::GattErrorCode error);
82
73 // Called when value changed event occurs. 83 // Called when value changed event occurs.
74 void OnChanged(JNIEnv* env, 84 void OnChanged(JNIEnv* env,
75 const base::android::JavaParamRef<jobject>& jcaller, 85 const base::android::JavaParamRef<jobject>& jcaller,
76 const base::android::JavaParamRef<jbyteArray>& value); 86 const base::android::JavaParamRef<jbyteArray>& value);
77 87
78 // Called when Read operation completes. 88 // Called when Read operation completes.
79 void OnRead(JNIEnv* env, 89 void OnRead(JNIEnv* env,
80 const base::android::JavaParamRef<jobject>& jcaller, 90 const base::android::JavaParamRef<jobject>& jcaller,
81 int32_t status, 91 int32_t status,
82 const base::android::JavaParamRef<jbyteArray>& value); 92 const base::android::JavaParamRef<jbyteArray>& value);
83 93
84 // Called when Write operation completes. 94 // Called when Write operation completes.
85 void OnWrite(JNIEnv* env, 95 void OnWrite(JNIEnv* env,
86 const base::android::JavaParamRef<jobject>& jcaller, 96 const base::android::JavaParamRef<jobject>& jcaller,
87 int32_t status); 97 int32_t status);
88 98
89 // Creates a Bluetooth GATT descriptor object and adds it to |descriptors_|, 99 // Creates a Bluetooth GATT descriptor object and adds it to |descriptors_|,
90 // DCHECKing that it has not already been created. 100 // DCHECKing that it has not already been created.
91 void CreateGattRemoteDescriptor( 101 void CreateGattRemoteDescriptor(
92 JNIEnv* env, 102 JNIEnv* env,
93 const base::android::JavaParamRef<jobject>& caller, 103 const base::android::JavaParamRef<jobject>& caller,
94 const base::android::JavaParamRef<jstring>& instanceId, 104 const base::android::JavaParamRef<jstring>& instanceId,
95 const base::android::JavaParamRef< 105 const base::android::JavaParamRef<
96 jobject>& /* BluetoothGattDescriptorWrapper */ 106 jobject>& /* BluetoothGattDescriptorWrapper */
97 bluetooth_gatt_descriptor_wrapper, 107 bluetooth_gatt_descriptor_wrapper,
98 const base::android::JavaParamRef< 108 const base::android::JavaParamRef<
99 jobject>& /* ChromeBluetoothCharacteristic */ 109 jobject>& /* ChromeBluetoothCharacteristic */
100 chrome_bluetooth_characteristic); 110 chrome_bluetooth_characteristic);
101 111
102 protected:
103 void SubscribeToNotifications(BluetoothRemoteGattDescriptor* ccc_descriptor,
104 const base::Closure& callback,
105 const ErrorCallback& error_callback) override;
106 void UnsubscribeFromNotifications(
107 BluetoothRemoteGattDescriptor* ccc_descriptor,
108 const base::Closure& callback,
109 const ErrorCallback& error_callback) override;
110
111 private: 112 private:
112 BluetoothRemoteGattCharacteristicAndroid( 113 BluetoothRemoteGattCharacteristicAndroid(
113 BluetoothAdapterAndroid* adapter, 114 BluetoothAdapterAndroid* adapter,
114 BluetoothRemoteGattServiceAndroid* service, 115 BluetoothRemoteGattServiceAndroid* service,
115 const std::string& instance_id); 116 const std::string& instance_id);
116 117
117 // Populates |descriptors_| from Java objects if necessary. 118 // Populates |descriptors_| from Java objects if necessary.
118 void EnsureDescriptorsCreated() const; 119 void EnsureDescriptorsCreated() const;
119 120
120 // The adapter and service associated with this characteristic. It's ok to 121 // The adapter and service associated with this characteristic. It's ok to
121 // store a raw pointers here since they indirectly own this instance. 122 // store a raw pointers here since they indirectly own this instance.
122 BluetoothAdapterAndroid* adapter_; 123 BluetoothAdapterAndroid* adapter_;
123 BluetoothRemoteGattServiceAndroid* service_; 124 BluetoothRemoteGattServiceAndroid* service_;
124 125
125 // Java object 126 // Java object
126 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. 127 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic.
127 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; 128 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_;
128 129
129 // Adapter unique instance ID. 130 // Adapter unique instance ID.
130 std::string instance_id_; 131 std::string instance_id_;
131 132
133 // StartNotifySession callbacks and pending state.
134 typedef std::pair<NotifySessionCallback, ErrorCallback>
135 PendingStartNotifyCall;
136 std::vector<PendingStartNotifyCall> pending_start_notify_calls_;
137
132 // ReadRemoteCharacteristic callbacks and pending state. 138 // ReadRemoteCharacteristic callbacks and pending state.
133 bool read_pending_ = false; 139 bool read_pending_ = false;
134 ValueCallback read_callback_; 140 ValueCallback read_callback_;
135 ErrorCallback read_error_callback_; 141 ErrorCallback read_error_callback_;
136 142
137 // WriteRemoteCharacteristic callbacks and pending state. 143 // WriteRemoteCharacteristic callbacks and pending state.
138 bool write_pending_ = false; 144 bool write_pending_ = false;
139 base::Closure write_callback_; 145 base::Closure write_callback_;
140 ErrorCallback write_error_callback_; 146 ErrorCallback write_error_callback_;
141 147
142 std::vector<uint8_t> value_; 148 std::vector<uint8_t> value_;
143 149
144 // Map of descriptors, keyed by descriptor identifier. 150 // Map of descriptors, keyed by descriptor identifier.
145 base::ScopedPtrHashMap<std::string, 151 base::ScopedPtrHashMap<std::string,
146 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid>> 152 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid>>
147 descriptors_; 153 descriptors_;
148 154
149 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); 155 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid);
150 }; 156 };
151 157
152 } // namespace device 158 } // namespace device
153 159
154 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ 160 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698