Commit 2f3d6fd3 authored by Conley Owens's avatar Conley Owens Committed by Commit Bot

bluetooth: windows: Mark characteristic discovered

Currently characteristics are not getting marked discovered.  This
change fixes that.

At the moment, this does not bubble up a services discovered event, so
a test for this will be made in a subsequent change.
https://chromium-review.googlesource.com/c/chromium/src/+/730653/

BUG=507419

Change-Id: Ie6a510ee2ae6d97e34760822fe7b01f65e28337d
Reviewed-on: https://chromium-review.googlesource.com/735983
Commit-Queue: Conley Owens <cco3@chromium.org>
Reviewed-by: default avatarVincent Scheib <scheib@chromium.org>
Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517677}
parent 0598d65f
...@@ -27,6 +27,7 @@ BluetoothRemoteGattCharacteristicWin::BluetoothRemoteGattCharacteristicWin( ...@@ -27,6 +27,7 @@ BluetoothRemoteGattCharacteristicWin::BluetoothRemoteGattCharacteristicWin(
characteristic_added_notified_(false), characteristic_added_notified_(false),
characteristic_value_read_or_write_in_progress_(false), characteristic_value_read_or_write_in_progress_(false),
gatt_event_handle_(nullptr), gatt_event_handle_(nullptr),
discovery_pending_count_(0),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); DCHECK(ui_task_runner_->RunsTasksInCurrentSequence());
DCHECK(parent_service_); DCHECK(parent_service_);
...@@ -205,6 +206,7 @@ void BluetoothRemoteGattCharacteristicWin::WriteRemoteCharacteristic( ...@@ -205,6 +206,7 @@ void BluetoothRemoteGattCharacteristicWin::WriteRemoteCharacteristic(
void BluetoothRemoteGattCharacteristicWin::Update() { void BluetoothRemoteGattCharacteristicWin::Update() {
DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); DCHECK(ui_task_runner_->RunsTasksInCurrentSequence());
++discovery_pending_count_;
task_manager_->PostGetGattIncludedDescriptors( task_manager_->PostGetGattIncludedDescriptors(
parent_service_->GetServicePath(), characteristic_info_.get(), parent_service_->GetServicePath(), characteristic_info_.get(),
base::Bind(&BluetoothRemoteGattCharacteristicWin:: base::Bind(&BluetoothRemoteGattCharacteristicWin::
...@@ -251,6 +253,10 @@ void BluetoothRemoteGattCharacteristicWin::OnGetIncludedDescriptorsCallback( ...@@ -251,6 +253,10 @@ void BluetoothRemoteGattCharacteristicWin::OnGetIncludedDescriptorsCallback(
characteristic_added_notified_ = true; characteristic_added_notified_ = true;
parent_service_->GetWinAdapter()->NotifyGattCharacteristicAdded(this); parent_service_->GetWinAdapter()->NotifyGattCharacteristicAdded(this);
} }
// Report discovery complete.
if (--discovery_pending_count_ == 0)
parent_service_->GattCharacteristicDiscoveryComplete(this);
} }
void BluetoothRemoteGattCharacteristicWin::UpdateIncludedDescriptors( void BluetoothRemoteGattCharacteristicWin::UpdateIncludedDescriptors(
......
...@@ -130,6 +130,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin ...@@ -130,6 +130,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin
// GATT event handle returned by GattEventRegistrationCallback. // GATT event handle returned by GattEventRegistrationCallback.
PVOID gatt_event_handle_; PVOID gatt_event_handle_;
// Counts the number of asynchronous operations that are discovering
// descriptors.
int discovery_pending_count_;
base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin);
}; };
......
...@@ -21,7 +21,7 @@ namespace device { ...@@ -21,7 +21,7 @@ namespace device {
#if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
class BluetoothRemoteGattServiceTest : public BluetoothTest {}; class BluetoothRemoteGattServiceTest : public BluetoothTest {};
#endif #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
// Android is excluded because it fires a single discovery event per device. // Android is excluded because it fires a single discovery event per device.
#if defined(OS_WIN) || defined(OS_MACOSX) #if defined(OS_WIN) || defined(OS_MACOSX)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment