| Index: device/bluetooth/bluetooth_task_manager_win.cc
|
| diff --git a/device/bluetooth/bluetooth_task_manager_win.cc b/device/bluetooth/bluetooth_task_manager_win.cc
|
| index bcb3823e094a32b7ac84faaa29288fb74af275d2..b89d69d71132da5151782a2c4c2fb650b78e9182 100644
|
| --- a/device/bluetooth/bluetooth_task_manager_win.cc
|
| +++ b/device/bluetooth/bluetooth_task_manager_win.cc
|
| @@ -844,6 +844,26 @@ void BluetoothTaskManagerWin::WriteGattCharacteristicValue(
|
| ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, hr));
|
| }
|
|
|
| +void BluetoothTaskManagerWin::RegisterGattCharacteristicValueChangedEvent(
|
| + base::FilePath service_path,
|
| + BTH_LE_GATT_CHARACTERISTIC characteristic,
|
| + const GattEventRegistrationCallback& callback,
|
| + PFNBLUETOOTH_GATT_EVENT_CALLBACK registered_callback,
|
| + void* context) {
|
| + BLUETOOTH_GATT_EVENT_HANDLE event_handle = NULL;
|
| +
|
| + BLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION event_parameter;
|
| + memcpy(&(event_parameter.Characteristics[0]), &characteristic,
|
| + sizeof(BTH_LE_GATT_CHARACTERISTIC));
|
| + event_parameter.NumCharacteristics = 1;
|
| + HRESULT hr =
|
| + win::BluetoothLowEnergyWrapper::GetInstance()->RegisterGattEvents(
|
| + service_path, CharacteristicValueChangedEvent, &event_parameter,
|
| + registered_callback, context, &event_handle);
|
| +
|
| + ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, event_handle, hr));
|
| +}
|
| +
|
| void BluetoothTaskManagerWin::PostGetGattIncludedCharacteristics(
|
| const base::FilePath& service_path,
|
| const BluetoothUUID& uuid,
|
| @@ -876,8 +896,6 @@ void BluetoothTaskManagerWin::PostReadGattCharacteristicValue(
|
| FROM_HERE,
|
| base::Bind(&BluetoothTaskManagerWin::ReadGattCharacteristicValue, this,
|
| service_path, *characteristic, callback));
|
| - FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_,
|
| - OnAttemptReadGattCharacteristic());
|
| }
|
|
|
| void BluetoothTaskManagerWin::PostWriteGattCharacteristicValue(
|
| @@ -890,8 +908,28 @@ void BluetoothTaskManagerWin::PostWriteGattCharacteristicValue(
|
| FROM_HERE,
|
| base::Bind(&BluetoothTaskManagerWin::WriteGattCharacteristicValue, this,
|
| service_path, *characteristic, new_value, callback));
|
| - FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_,
|
| - OnAttemptWriteGattCharacteristic());
|
| +}
|
| +
|
| +void BluetoothTaskManagerWin::PostRegisterGattCharacteristicValueChangedEvent(
|
| + const base::FilePath& service_path,
|
| + const PBTH_LE_GATT_CHARACTERISTIC characteristic,
|
| + const GattEventRegistrationCallback& callback,
|
| + PFNBLUETOOTH_GATT_EVENT_CALLBACK registered_callback,
|
| + void* context) {
|
| + DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
|
| + bluetooth_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &BluetoothTaskManagerWin::RegisterGattCharacteristicValueChangedEvent,
|
| + this, service_path, *characteristic, callback, registered_callback,
|
| + context));
|
| +}
|
| +
|
| +void BluetoothTaskManagerWin::UnregisterGattCharacteristicValueChangedEvent(
|
| + BLUETOOTH_GATT_EVENT_HANDLE event_handle) {
|
| + DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
|
| + win::BluetoothLowEnergyWrapper::GetInstance()->UnregisterGattEvent(
|
| + event_handle);
|
| }
|
|
|
| } // namespace device
|
|
|