| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ID Not In Map Note: | 5 // ID Not In Map Note: |
| 6 // A service, characteristic, or descriptor ID not in the corresponding | 6 // A service, characteristic, or descriptor ID not in the corresponding |
| 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, | 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, |
| 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer | 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer |
| 9 // obtains the corresponding ID from this class and it will be added to the map | 9 // obtains the corresponding ID from this class and it will be added to the map |
| 10 // at that time. | 10 // at that time. |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 device::BluetoothAdapter* adapter, | 510 device::BluetoothAdapter* adapter, |
| 511 bool powered) { | 511 bool powered) { |
| 512 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 512 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 513 const BluetoothChooser::AdapterPresence presence = | 513 const BluetoothChooser::AdapterPresence presence = |
| 514 powered ? BluetoothChooser::AdapterPresence::POWERED_ON | 514 powered ? BluetoothChooser::AdapterPresence::POWERED_ON |
| 515 : BluetoothChooser::AdapterPresence::POWERED_OFF; | 515 : BluetoothChooser::AdapterPresence::POWERED_OFF; |
| 516 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( | 516 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( |
| 517 &request_device_sessions_); | 517 &request_device_sessions_); |
| 518 !iter.IsAtEnd(); iter.Advance()) { | 518 !iter.IsAtEnd(); iter.Advance()) { |
| 519 RequestDeviceSession* session = iter.GetCurrentValue(); | 519 RequestDeviceSession* session = iter.GetCurrentValue(); |
| 520 |
| 521 // Stop ongoing discovery session if power is off. |
| 522 if (!powered && session->discovery_session) { |
| 523 StopDiscoverySession(std::move(session->discovery_session)); |
| 524 } |
| 525 |
| 520 if (session->chooser) | 526 if (session->chooser) |
| 521 session->chooser->SetAdapterPresence(presence); | 527 session->chooser->SetAdapterPresence(presence); |
| 522 } | 528 } |
| 529 |
| 530 // Stop the timer so that we don't change the state of the chooser |
| 531 // when timer expires. |
| 532 if (!powered) { |
| 533 discovery_session_timer_.Stop(); |
| 534 } |
| 523 } | 535 } |
| 524 | 536 |
| 525 void BluetoothDispatcherHost::DeviceAdded(device::BluetoothAdapter* adapter, | 537 void BluetoothDispatcherHost::DeviceAdded(device::BluetoothAdapter* adapter, |
| 526 device::BluetoothDevice* device) { | 538 device::BluetoothDevice* device) { |
| 527 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 539 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 528 VLOG(1) << "Adding device to all choosers: " << device->GetAddress(); | 540 VLOG(1) << "Adding device to all choosers: " << device->GetAddress(); |
| 529 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( | 541 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( |
| 530 &request_device_sessions_); | 542 &request_device_sessions_); |
| 531 !iter.IsAtEnd(); iter.Advance()) { | 543 !iter.IsAtEnd(); iter.Advance()) { |
| 532 RequestDeviceSession* session = iter.GetCurrentValue(); | 544 RequestDeviceSession* session = iter.GetCurrentValue(); |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 | 1553 |
| 1542 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( | 1554 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( |
| 1543 int frame_routing_id, | 1555 int frame_routing_id, |
| 1544 const std::string& characteristic_instance_id) { | 1556 const std::string& characteristic_instance_id) { |
| 1545 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), | 1557 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), |
| 1546 characteristic_instance_id) | 1558 characteristic_instance_id) |
| 1547 .outcome != CacheQueryOutcome::BAD_RENDERER; | 1559 .outcome != CacheQueryOutcome::BAD_RENDERER; |
| 1548 } | 1560 } |
| 1549 | 1561 |
| 1550 } // namespace content | 1562 } // namespace content |
| OLD | NEW |