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

Side by Side Diff: device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h

Issue 2728623004: Fix getting notified twice after subscribe to notifications and call readValue (Closed)
Patch Set: address comments Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <map> 10 #include <map>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 std::vector<device::BluetoothRemoteGattDescriptor*> GetDescriptors() 56 std::vector<device::BluetoothRemoteGattDescriptor*> GetDescriptors()
57 const override; 57 const override;
58 device::BluetoothRemoteGattDescriptor* GetDescriptor( 58 device::BluetoothRemoteGattDescriptor* GetDescriptor(
59 const std::string& identifier) const override; 59 const std::string& identifier) const override;
60 void ReadRemoteCharacteristic(const ValueCallback& callback, 60 void ReadRemoteCharacteristic(const ValueCallback& callback,
61 const ErrorCallback& error_callback) override; 61 const ErrorCallback& error_callback) override;
62 void WriteRemoteCharacteristic(const std::vector<uint8_t>& value, 62 void WriteRemoteCharacteristic(const std::vector<uint8_t>& value,
63 const base::Closure& callback, 63 const base::Closure& callback,
64 const ErrorCallback& error_callback) override; 64 const ErrorCallback& error_callback) override;
65 65
66 bool characteristic_value_read_in_progress() {
67 return characteristic_value_read_in_progress_;
68 }
69
70 void set_characteristic_value_read_in_progress(bool in_progress) {
71 characteristic_value_read_in_progress_ = in_progress;
72 }
73
66 protected: 74 protected:
67 void SubscribeToNotifications( 75 void SubscribeToNotifications(
68 device::BluetoothRemoteGattDescriptor* ccc_descriptor, 76 device::BluetoothRemoteGattDescriptor* ccc_descriptor,
69 const base::Closure& callback, 77 const base::Closure& callback,
70 const ErrorCallback& error_callback) override; 78 const ErrorCallback& error_callback) override;
71 void UnsubscribeFromNotifications( 79 void UnsubscribeFromNotifications(
72 device::BluetoothRemoteGattDescriptor* ccc_descriptor, 80 device::BluetoothRemoteGattDescriptor* ccc_descriptor,
73 const base::Closure& callback, 81 const base::Closure& callback,
74 const ErrorCallback& error_callback) override; 82 const ErrorCallback& error_callback) override;
75 83
(...skipping 27 matching lines...) Expand all
103 // Called by dbus:: on successful completion of a request to stop 111 // Called by dbus:: on successful completion of a request to stop
104 // notifications. 112 // notifications.
105 void OnStopNotifySuccess(const base::Closure& callback); 113 void OnStopNotifySuccess(const base::Closure& callback);
106 114
107 // Called by dbus:: on unsuccessful completion of a request to stop 115 // Called by dbus:: on unsuccessful completion of a request to stop
108 // notifications. 116 // notifications.
109 void OnStopNotifyError(const base::Closure& callback, 117 void OnStopNotifyError(const base::Closure& callback,
110 const std::string& error_name, 118 const std::string& error_name,
111 const std::string& error_message); 119 const std::string& error_message);
112 120
113 // Called by dbus:: on unsuccessful completion of a request to read or write 121 // Called by dbus:: on unsuccessful completion of a request to read
114 // the characteristic value. 122 // the characteristic value.
115 void OnError(const ErrorCallback& error_callback, 123 void OnReadError(const ErrorCallback& error_callback,
116 const std::string& error_name, 124 const std::string& error_name,
117 const std::string& error_message); 125 const std::string& error_message);
126
127 // Called by dbus:: on unsuccessful completion of a request to write
128 // the characteristic value.
129 void OnWriteError(const ErrorCallback& error_callback,
130 const std::string& error_name,
131 const std::string& error_message);
118 132
119 // True, if there exists a Bluez notify session. 133 // True, if there exists a Bluez notify session.
120 bool has_notify_session_; 134 bool has_notify_session_;
121 135
122 // TODO(rkc): Investigate and fix ownership of the descriptor objects in this 136 // TODO(rkc): Investigate and fix ownership of the descriptor objects in this
123 // map. See crbug.com/604166. 137 // map. See crbug.com/604166.
124 using DescriptorMap = 138 using DescriptorMap =
125 std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorBlueZ*>; 139 std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorBlueZ*>;
126 140
127 // Mapping from GATT descriptor object paths to descriptor objects owned by 141 // Mapping from GATT descriptor object paths to descriptor objects owned by
128 // this characteristic. Since the BlueZ implementation uses object paths 142 // this characteristic. Since the BlueZ implementation uses object paths
129 // as unique identifiers, we also use this mapping to return descriptors by 143 // as unique identifiers, we also use this mapping to return descriptors by
130 // identifier. 144 // identifier.
131 DescriptorMap descriptors_; 145 DescriptorMap descriptors_;
132 146
133 // The GATT service this GATT characteristic belongs to. 147 // The GATT service this GATT characteristic belongs to.
134 BluetoothRemoteGattServiceBlueZ* service_; 148 BluetoothRemoteGattServiceBlueZ* service_;
135 149
150 // True if a gatt read request is in progress.
151 bool characteristic_value_read_in_progress_;
152
136 // Note: This should remain the last member so it'll be destroyed and 153 // Note: This should remain the last member so it'll be destroyed and
137 // invalidate its weak pointers before any other members are destroyed. 154 // invalidate its weak pointers before any other members are destroyed.
138 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> 155 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ>
139 weak_ptr_factory_; 156 weak_ptr_factory_;
140 157
141 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); 158 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ);
142 }; 159 };
143 160
144 } // namespace bluez 161 } // namespace bluez
145 162
146 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ 163 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698