Commit 518c599b authored by sonnysasaka's avatar sonnysasaka Committed by Commit bot

PostTask MaybeReleaseAdapter in BluetoothEventRouter::AdapterDiscoveringChanged

Calling MaybeReleaseAdapter directly from
BluetoothEventRouter::AdapterDiscoveringChanged could be a problem since
this can happen:
BluetoothAdapterBlueZ::AdapterPropertyChanged ->
BluetoothAdapterBlueZ::DiscoveringChanged ->
BluetoothEventRouter::AdapterDiscoveringChanged -> MaybeReleaseAdapter

If BluetoothEventRouter is the only pointer holder left then the caller
of BluetoothEventRouter::AdapterDiscoveringChanged could be gone even
before that function returns.

BUG=710216

Review-Url: https://codereview.chromium.org/2852773002
Cr-Commit-Position: refs/heads/master@{#468180}
parent b399a054
...@@ -329,8 +329,11 @@ void BluetoothEventRouter::AdapterDiscoveringChanged( ...@@ -329,8 +329,11 @@ void BluetoothEventRouter::AdapterDiscoveringChanged(
DispatchAdapterStateEvent(); DispatchAdapterStateEvent();
// Release the adapter after dispatching the event. // Release the adapter after dispatching the event.
if (!discovering) if (!discovering) {
MaybeReleaseAdapter(); base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&BluetoothEventRouter::MaybeReleaseAdapter,
weak_ptr_factory_.GetWeakPtr()));
}
} }
void BluetoothEventRouter::DeviceAdded(device::BluetoothAdapter* adapter, void BluetoothEventRouter::DeviceAdded(device::BluetoothAdapter* adapter,
......
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