| OLD | NEW |
| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 typedef base::Callback<void(HRESULT)> HResultCallback; | 128 typedef base::Callback<void(HRESULT)> HResultCallback; |
| 129 typedef base::Callback< | 129 typedef base::Callback< |
| 130 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)> | 130 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)> |
| 131 GetGattIncludedCharacteristicsCallback; | 131 GetGattIncludedCharacteristicsCallback; |
| 132 typedef base::Callback< | 132 typedef base::Callback< |
| 133 void(scoped_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)> | 133 void(scoped_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)> |
| 134 GetGattIncludedDescriptorsCallback; | 134 GetGattIncludedDescriptorsCallback; |
| 135 typedef base::Callback<void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>, | 135 typedef base::Callback<void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>, |
| 136 HRESULT)> | 136 HRESULT)> |
| 137 ReadGattCharacteristicValueCallback; | 137 ReadGattCharacteristicValueCallback; |
| 138 typedef base::Callback<void(BLUETOOTH_GATT_EVENT_HANDLE, HRESULT)> |
| 139 GattEventRegistrationCallback; |
| 138 | 140 |
| 139 // Get all included characteristics of a given service. The service is | 141 // Get all included characteristics of a given service. The service is |
| 140 // uniquely identified by its |uuid| and |attribute_handle| with service | 142 // uniquely identified by its |uuid| and |attribute_handle| with service |
| 141 // device |service_path|. The result is returned asynchronously through | 143 // device |service_path|. The result is returned asynchronously through |
| 142 // |callback|. | 144 // |callback|. |
| 143 void PostGetGattIncludedCharacteristics( | 145 void PostGetGattIncludedCharacteristics( |
| 144 const base::FilePath& service_path, | 146 const base::FilePath& service_path, |
| 145 const BluetoothUUID& uuid, | 147 const BluetoothUUID& uuid, |
| 146 uint16_t attribute_handle, | 148 uint16_t attribute_handle, |
| 147 const GetGattIncludedCharacteristicsCallback& callback); | 149 const GetGattIncludedCharacteristicsCallback& callback); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 163 | 165 |
| 164 // Post write the value of a given |characteristic| in service with | 166 // Post write the value of a given |characteristic| in service with |
| 165 // |service_path| to |new_value|. The operation result is returned | 167 // |service_path| to |new_value|. The operation result is returned |
| 166 // asynchronously through |callback|. | 168 // asynchronously through |callback|. |
| 167 void PostWriteGattCharacteristicValue( | 169 void PostWriteGattCharacteristicValue( |
| 168 const base::FilePath& service_path, | 170 const base::FilePath& service_path, |
| 169 const PBTH_LE_GATT_CHARACTERISTIC characteristic, | 171 const PBTH_LE_GATT_CHARACTERISTIC characteristic, |
| 170 const std::vector<uint8_t>& new_value, | 172 const std::vector<uint8_t>& new_value, |
| 171 const HResultCallback& callback); | 173 const HResultCallback& callback); |
| 172 | 174 |
| 175 // Post register a given |characteristic|'s value change notification of a |
| 176 // service with |service_path|. |registered_callback| is the function to be |
| 177 // invoked if the event occured. |context| is a void pointer from caller which |
| 178 // will be given back to caller through |registered_callback|. The operation |
| 179 // result is returned asynchronously through |callback|. |
| 180 void PostRegisterGattCharacteristicValueChangedEvent( |
| 181 const base::FilePath& service_path, |
| 182 const PBTH_LE_GATT_CHARACTERISTIC characteristic, |
| 183 const GattEventRegistrationCallback& callback, |
| 184 PFNBLUETOOTH_GATT_EVENT_CALLBACK registered_callback, |
| 185 void* context); |
| 186 |
| 187 // Unregister characteristic value change notification. |event_handle| was |
| 188 // returned by PostRegisterGattCharacteristicValueChangedEvent. |
| 189 void UnregisterGattCharacteristicValueChangedEvent( |
| 190 BLUETOOTH_GATT_EVENT_HANDLE event_handle); |
| 191 |
| 173 private: | 192 private: |
| 174 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; | 193 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; |
| 175 friend class BluetoothTaskManagerWinTest; | 194 friend class BluetoothTaskManagerWinTest; |
| 176 | 195 |
| 177 static const int kPollIntervalMs; | 196 static const int kPollIntervalMs; |
| 178 | 197 |
| 179 virtual ~BluetoothTaskManagerWin(); | 198 virtual ~BluetoothTaskManagerWin(); |
| 180 | 199 |
| 181 // Logs Win32 errors occurring during polling on the worker thread. The method | 200 // Logs Win32 errors occurring during polling on the worker thread. The method |
| 182 // may discard messages to avoid logging being too verbose. | 201 // may discard messages to avoid logging being too verbose. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 BTH_LE_GATT_CHARACTERISTIC characteristic, | 290 BTH_LE_GATT_CHARACTERISTIC characteristic, |
| 272 const GetGattIncludedDescriptorsCallback& callback); | 291 const GetGattIncludedDescriptorsCallback& callback); |
| 273 void ReadGattCharacteristicValue( | 292 void ReadGattCharacteristicValue( |
| 274 base::FilePath device_path, | 293 base::FilePath device_path, |
| 275 BTH_LE_GATT_CHARACTERISTIC characteristic, | 294 BTH_LE_GATT_CHARACTERISTIC characteristic, |
| 276 const ReadGattCharacteristicValueCallback& callback); | 295 const ReadGattCharacteristicValueCallback& callback); |
| 277 void WriteGattCharacteristicValue(base::FilePath service_path, | 296 void WriteGattCharacteristicValue(base::FilePath service_path, |
| 278 BTH_LE_GATT_CHARACTERISTIC characteristic, | 297 BTH_LE_GATT_CHARACTERISTIC characteristic, |
| 279 std::vector<uint8_t> new_value, | 298 std::vector<uint8_t> new_value, |
| 280 const HResultCallback& callback); | 299 const HResultCallback& callback); |
| 300 void RegisterGattCharacteristicValueChangedEvent( |
| 301 base::FilePath service_path, |
| 302 BTH_LE_GATT_CHARACTERISTIC characteristic, |
| 303 const GattEventRegistrationCallback& callback, |
| 304 PFNBLUETOOTH_GATT_EVENT_CALLBACK registered_callback, |
| 305 void* context); |
| 281 | 306 |
| 282 // UI task runner reference. | 307 // UI task runner reference. |
| 283 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 308 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 284 | 309 |
| 285 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 310 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| 286 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; | 311 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; |
| 287 | 312 |
| 288 // List of observers interested in event notifications. | 313 // List of observers interested in event notifications. |
| 289 base::ObserverList<Observer> observers_; | 314 base::ObserverList<Observer> observers_; |
| 290 | 315 |
| 291 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle | 316 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle |
| 292 // the close of |adapter_handle_|. | 317 // the close of |adapter_handle_|. |
| 293 HANDLE adapter_handle_; | 318 HANDLE adapter_handle_; |
| 294 | 319 |
| 295 // indicates whether the adapter is in discovery mode or not. | 320 // indicates whether the adapter is in discovery mode or not. |
| 296 bool discovering_; | 321 bool discovering_; |
| 297 | 322 |
| 298 // Use for discarding too many log messages. | 323 // Use for discarding too many log messages. |
| 299 base::TimeTicks current_logging_batch_ticks_; | 324 base::TimeTicks current_logging_batch_ticks_; |
| 300 int current_logging_batch_count_; | 325 int current_logging_batch_count_; |
| 301 | 326 |
| 302 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); | 327 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); |
| 303 }; | 328 }; |
| 304 | 329 |
| 305 } // namespace device | 330 } // namespace device |
| 306 | 331 |
| 307 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ | 332 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |
| OLD | NEW |