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 e5b96d93df90afdb7f89ceea2fdcf5350cc6cea2..3a8a44ef2601d9440ebc4c11e6b074da4d222081 100644 |
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
@@ -486,9 +486,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, |