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

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: rebase Created 4 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 (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 register a given |characteristic|'s value change notification of a
175 // service with |service_path|. |registered_callback| is the function to be
176 // invoked if the event occured. The operation result is returned
177 // asynchronously through |callback|.
ortuno 2016/03/15 02:55:31 Post a task to register to receive value changed n
gogerald1 2016/03/15 18:28:23 Done.
178 void PostRegisterGattCharacteristicValueChangedEvent(
179 const base::FilePath& service_path,
180 const PBTH_LE_GATT_CHARACTERISTIC characteristic,
181 const GattEventRegistrationCallback& callback,
182 const GattCharacteristicValueChangedCallback& registered_callback);
183
184 // Post unregister characteristic value change notification. |event_handle|
ortuno 2016/03/15 02:55:31 Post a task to unregister from value change notifi
gogerald1 2016/03/15 18:28:23 Done.
185 // was returned by PostRegisterGattCharacteristicValueChangedEvent.
186 void PostUnregisterGattCharacteristicValueChangedEvent(PVOID event_handle);
187
173 private: 188 private:
174 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; 189 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>;
175 friend class BluetoothTaskManagerWinTest; 190 friend class BluetoothTaskManagerWinTest;
176 191
177 static const int kPollIntervalMs; 192 static const int kPollIntervalMs;
178 193
179 virtual ~BluetoothTaskManagerWin(); 194 virtual ~BluetoothTaskManagerWin();
180 195
181 // Logs Win32 errors occurring during polling on the worker thread. The method 196 // Logs Win32 errors occurring during polling on the worker thread. The method
182 // may discard messages to avoid logging being too verbose. 197 // 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, 286 BTH_LE_GATT_CHARACTERISTIC characteristic,
272 const GetGattIncludedDescriptorsCallback& callback); 287 const GetGattIncludedDescriptorsCallback& callback);
273 void ReadGattCharacteristicValue( 288 void ReadGattCharacteristicValue(
274 base::FilePath device_path, 289 base::FilePath device_path,
275 BTH_LE_GATT_CHARACTERISTIC characteristic, 290 BTH_LE_GATT_CHARACTERISTIC characteristic,
276 const ReadGattCharacteristicValueCallback& callback); 291 const ReadGattCharacteristicValueCallback& callback);
277 void WriteGattCharacteristicValue(base::FilePath service_path, 292 void WriteGattCharacteristicValue(base::FilePath service_path,
278 BTH_LE_GATT_CHARACTERISTIC characteristic, 293 BTH_LE_GATT_CHARACTERISTIC characteristic,
279 std::vector<uint8_t> new_value, 294 std::vector<uint8_t> new_value,
280 const HResultCallback& callback); 295 const HResultCallback& callback);
296 void RegisterGattCharacteristicValueChangedEvent(
297 base::FilePath service_path,
298 BTH_LE_GATT_CHARACTERISTIC characteristic,
299 const GattEventRegistrationCallback& callback,
300 const GattCharacteristicValueChangedCallback& registered_callback);
301 void UnregisterGattCharacteristicValueChangedEvent(PVOID event_handle);
281 302
282 // UI task runner reference. 303 // UI task runner reference.
283 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 304 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
284 305
285 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 306 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
286 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; 307 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_;
287 308
288 // List of observers interested in event notifications. 309 // List of observers interested in event notifications.
289 base::ObserverList<Observer> observers_; 310 base::ObserverList<Observer> observers_;
290 311
291 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle 312 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle
292 // the close of |adapter_handle_|. 313 // the close of |adapter_handle_|.
293 HANDLE adapter_handle_; 314 HANDLE adapter_handle_;
294 315
295 // indicates whether the adapter is in discovery mode or not. 316 // indicates whether the adapter is in discovery mode or not.
296 bool discovering_; 317 bool discovering_;
297 318
298 // Use for discarding too many log messages. 319 // Use for discarding too many log messages.
299 base::TimeTicks current_logging_batch_ticks_; 320 base::TimeTicks current_logging_batch_ticks_;
300 int current_logging_batch_count_; 321 int current_logging_batch_count_;
301 322
302 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); 323 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin);
303 }; 324 };
304 325
305 } // namespace device 326 } // namespace device
306 327
307 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 328 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698