Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc |
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
index 22ad2c63fd955f1db5bb3032a2cc1020f01c2ff4..23985e041f8daa2177276f280e6b00dc8875f275 100644 |
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
@@ -517,9 +517,21 @@ void BluetoothDispatcherHost::AdapterPoweredChanged( |
&request_device_sessions_); |
!iter.IsAtEnd(); iter.Advance()) { |
RequestDeviceSession* session = iter.GetCurrentValue(); |
+ |
+ // Stop ongoing discovery session if power is off. |
+ if (!powered && session->discovery_session) { |
+ StopDiscoverySession(std::move(session->discovery_session)); |
+ } |
+ |
if (session->chooser) |
session->chooser->SetAdapterPresence(presence); |
} |
+ |
+ // Stop the timer so that we don't change the state of the chooser |
+ // when timer expires. |
+ if (!powered) { |
+ discovery_session_timer_.Stop(); |
+ } |
} |
void BluetoothDispatcherHost::DeviceAdded(device::BluetoothAdapter* adapter, |