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

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

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move comments 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TASK_MANAGER_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 virtual void DiscoveryStarted(bool success) {} 92 virtual void DiscoveryStarted(bool success) {}
93 virtual void DiscoveryStopped() {} 93 virtual void DiscoveryStopped() {}
94 // Called when the adapter has just been polled for the list of *all* known 94 // Called when the adapter has just been polled for the list of *all* known
95 // devices. This includes devices previously paired, devices paired using 95 // devices. This includes devices previously paired, devices paired using
96 // the underlying Operating System UI, and devices discovered recently due 96 // the underlying Operating System UI, and devices discovered recently due
97 // to an active discovery session. Note that for a given device (address), 97 // to an active discovery session. Note that for a given device (address),
98 // the associated state can change over time. For example, during a 98 // the associated state can change over time. For example, during a
99 // discovery session, the "friendly" name may initially be "unknown" before 99 // discovery session, the "friendly" name may initially be "unknown" before
100 // the actual name is retrieved in subsequent poll events. 100 // the actual name is retrieved in subsequent poll events.
101 virtual void DevicesPolled(const ScopedVector<DeviceState>& devices) {} 101 virtual void DevicesPolled(const ScopedVector<DeviceState>& devices) {}
102 virtual void OnAttemptReadGattCharacteristic() {}
103 virtual void OnAttemptWriteGattCharacteristic() {}
104 }; 102 };
105 103
106 explicit BluetoothTaskManagerWin( 104 explicit BluetoothTaskManagerWin(
107 scoped_refptr<base::SequencedTaskRunner> ui_task_runner); 105 scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
108 106
109 static BluetoothUUID BluetoothLowEnergyUuidToBluetoothUuid( 107 static BluetoothUUID BluetoothLowEnergyUuidToBluetoothUuid(
110 const BTH_LE_UUID& bth_le_uuid); 108 const BTH_LE_UUID& bth_le_uuid);
111 109
112 void AddObserver(Observer* observer); 110 void AddObserver(Observer* observer);
113 void RemoveObserver(Observer* observer); 111 void RemoveObserver(Observer* observer);
(...skipping 14 matching lines...) Expand all
128 typedef base::Callback<void(HRESULT)> HResultCallback; 126 typedef base::Callback<void(HRESULT)> HResultCallback;
129 typedef base::Callback< 127 typedef base::Callback<
130 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)> 128 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)>
131 GetGattIncludedCharacteristicsCallback; 129 GetGattIncludedCharacteristicsCallback;
132 typedef base::Callback< 130 typedef base::Callback<
133 void(scoped_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)> 131 void(scoped_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)>
134 GetGattIncludedDescriptorsCallback; 132 GetGattIncludedDescriptorsCallback;
135 typedef base::Callback<void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>, 133 typedef base::Callback<void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>,
136 HRESULT)> 134 HRESULT)>
137 ReadGattCharacteristicValueCallback; 135 ReadGattCharacteristicValueCallback;
136 typedef base::Callback<void(scoped_ptr<std::vector<uint8_t>>)>
137 GattCharacteristicValueChangedCallback;
138 typedef base::Callback<void(PVOID, HRESULT)> GattEventRegistrationCallback;
138 139
139 // Get all included characteristics of a given service. The service is 140 // Get all included characteristics of a given service. The service is
140 // uniquely identified by its |uuid| and |attribute_handle| with service 141 // uniquely identified by its |uuid| and |attribute_handle| with service
141 // device |service_path|. The result is returned asynchronously through 142 // device |service_path|. The result is returned asynchronously through
142 // |callback|. 143 // |callback|.
143 void PostGetGattIncludedCharacteristics( 144 void PostGetGattIncludedCharacteristics(
144 const base::FilePath& service_path, 145 const base::FilePath& service_path,
145 const BluetoothUUID& uuid, 146 const BluetoothUUID& uuid,
146 uint16_t attribute_handle, 147 uint16_t attribute_handle,
147 const GetGattIncludedCharacteristicsCallback& callback); 148 const GetGattIncludedCharacteristicsCallback& callback);
(...skipping 15 matching lines...) Expand all
163 164
164 // Post write the value of a given |characteristic| in service with 165 // Post write the value of a given |characteristic| in service with
165 // |service_path| to |new_value|. The operation result is returned 166 // |service_path| to |new_value|. The operation result is returned
166 // asynchronously through |callback|. 167 // asynchronously through |callback|.
167 void PostWriteGattCharacteristicValue( 168 void PostWriteGattCharacteristicValue(
168 const base::FilePath& service_path, 169 const base::FilePath& service_path,
169 const PBTH_LE_GATT_CHARACTERISTIC characteristic, 170 const PBTH_LE_GATT_CHARACTERISTIC characteristic,
170 const std::vector<uint8_t>& new_value, 171 const std::vector<uint8_t>& new_value,
171 const HResultCallback& callback); 172 const HResultCallback& callback);
172 173
174 // Post a task to register to receive value changed notifications from
175 // |characteristic| in service with |service_path|. |ccc_descriptor| is the
176 // Client Characteristic Configuration descriptor. |registered_callback| is
177 // the function to be invoked if the event occured. The operation result is
178 // returned asynchronously through |callback|.
179 void PostRegisterGattCharacteristicValueChangedEvent(
180 const base::FilePath& service_path,
181 const PBTH_LE_GATT_CHARACTERISTIC characteristic,
182 const PBTH_LE_GATT_DESCRIPTOR ccc_descriptor,
183 const GattEventRegistrationCallback& callback,
184 const GattCharacteristicValueChangedCallback& registered_callback);
185
186 // Post a task to unregister from value change notifications. |event_handle|
187 // was returned by PostRegisterGattCharacteristicValueChangedEvent.
188 void PostUnregisterGattCharacteristicValueChangedEvent(PVOID event_handle);
189
173 private: 190 private:
174 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; 191 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>;
175 friend class BluetoothTaskManagerWinTest; 192 friend class BluetoothTaskManagerWinTest;
176 193
177 static const int kPollIntervalMs; 194 static const int kPollIntervalMs;
178 195
179 virtual ~BluetoothTaskManagerWin(); 196 virtual ~BluetoothTaskManagerWin();
180 197
181 // Logs Win32 errors occurring during polling on the worker thread. The method 198 // Logs Win32 errors occurring during polling on the worker thread. The method
182 // may discard messages to avoid logging being too verbose. 199 // may discard messages to avoid logging being too verbose.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 BTH_LE_GATT_CHARACTERISTIC characteristic, 288 BTH_LE_GATT_CHARACTERISTIC characteristic,
272 const GetGattIncludedDescriptorsCallback& callback); 289 const GetGattIncludedDescriptorsCallback& callback);
273 void ReadGattCharacteristicValue( 290 void ReadGattCharacteristicValue(
274 base::FilePath device_path, 291 base::FilePath device_path,
275 BTH_LE_GATT_CHARACTERISTIC characteristic, 292 BTH_LE_GATT_CHARACTERISTIC characteristic,
276 const ReadGattCharacteristicValueCallback& callback); 293 const ReadGattCharacteristicValueCallback& callback);
277 void WriteGattCharacteristicValue(base::FilePath service_path, 294 void WriteGattCharacteristicValue(base::FilePath service_path,
278 BTH_LE_GATT_CHARACTERISTIC characteristic, 295 BTH_LE_GATT_CHARACTERISTIC characteristic,
279 std::vector<uint8_t> new_value, 296 std::vector<uint8_t> new_value,
280 const HResultCallback& callback); 297 const HResultCallback& callback);
298 void RegisterGattCharacteristicValueChangedEvent(
299 base::FilePath service_path,
300 BTH_LE_GATT_CHARACTERISTIC characteristic,
301 BTH_LE_GATT_DESCRIPTOR ccc_descriptor,
302 const GattEventRegistrationCallback& callback,
303 const GattCharacteristicValueChangedCallback& registered_callback);
304 void UnregisterGattCharacteristicValueChangedEvent(PVOID event_handle);
281 305
282 // UI task runner reference. 306 // UI task runner reference.
283 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 307 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
284 308
285 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 309 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
286 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; 310 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_;
287 311
288 // List of observers interested in event notifications. 312 // List of observers interested in event notifications.
289 base::ObserverList<Observer> observers_; 313 base::ObserverList<Observer> observers_;
290 314
291 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle 315 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle
292 // the close of |adapter_handle_|. 316 // the close of |adapter_handle_|.
293 HANDLE adapter_handle_; 317 HANDLE adapter_handle_;
294 318
295 // indicates whether the adapter is in discovery mode or not. 319 // indicates whether the adapter is in discovery mode or not.
296 bool discovering_; 320 bool discovering_;
297 321
298 // Use for discarding too many log messages. 322 // Use for discarding too many log messages.
299 base::TimeTicks current_logging_batch_ticks_; 323 base::TimeTicks current_logging_batch_ticks_;
300 int current_logging_batch_count_; 324 int current_logging_batch_count_;
301 325
302 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); 326 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin);
303 }; 327 };
304 328
305 } // namespace device 329 } // namespace device
306 330
307 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 331 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_win.cc ('k') | device/bluetooth/bluetooth_task_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698