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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 device::BluetoothAdapter* adapter, | 479 device::BluetoothAdapter* adapter, |
480 bool powered) { | 480 bool powered) { |
481 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 481 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
482 const BluetoothChooser::AdapterPresence presence = | 482 const BluetoothChooser::AdapterPresence presence = |
483 powered ? BluetoothChooser::AdapterPresence::POWERED_ON | 483 powered ? BluetoothChooser::AdapterPresence::POWERED_ON |
484 : BluetoothChooser::AdapterPresence::POWERED_OFF; | 484 : BluetoothChooser::AdapterPresence::POWERED_OFF; |
485 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( | 485 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( |
486 &request_device_sessions_); | 486 &request_device_sessions_); |
487 !iter.IsAtEnd(); iter.Advance()) { | 487 !iter.IsAtEnd(); iter.Advance()) { |
488 RequestDeviceSession* session = iter.GetCurrentValue(); | 488 RequestDeviceSession* session = iter.GetCurrentValue(); |
| 489 |
| 490 // Stop ongoing discovery session if power is off. |
| 491 if (!powered && session->discovery_session) { |
| 492 StopDiscoverySession(std::move(session->discovery_session)); |
| 493 } |
| 494 |
489 if (session->chooser) | 495 if (session->chooser) |
490 session->chooser->SetAdapterPresence(presence); | 496 session->chooser->SetAdapterPresence(presence); |
491 } | 497 } |
| 498 |
| 499 // Stop the timer so that we don't change the state of the chooser |
| 500 // when timer expires. |
| 501 if (!powered) { |
| 502 discovery_session_timer_.Stop(); |
| 503 } |
492 } | 504 } |
493 | 505 |
494 void BluetoothDispatcherHost::DeviceAdded(device::BluetoothAdapter* adapter, | 506 void BluetoothDispatcherHost::DeviceAdded(device::BluetoothAdapter* adapter, |
495 device::BluetoothDevice* device) { | 507 device::BluetoothDevice* device) { |
496 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 508 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
497 VLOG(1) << "Adding device to all choosers: " << device->GetAddress(); | 509 VLOG(1) << "Adding device to all choosers: " << device->GetAddress(); |
498 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( | 510 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( |
499 &request_device_sessions_); | 511 &request_device_sessions_); |
500 !iter.IsAtEnd(); iter.Advance()) { | 512 !iter.IsAtEnd(); iter.Advance()) { |
501 RequestDeviceSession* session = iter.GetCurrentValue(); | 513 RequestDeviceSession* session = iter.GetCurrentValue(); |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1526 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1515 NOTIMPLEMENTED(); | 1527 NOTIMPLEMENTED(); |
1516 } | 1528 } |
1517 | 1529 |
1518 void BluetoothDispatcherHost::ShowNeedLocationLink() { | 1530 void BluetoothDispatcherHost::ShowNeedLocationLink() { |
1519 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1531 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1520 NOTIMPLEMENTED(); | 1532 NOTIMPLEMENTED(); |
1521 } | 1533 } |
1522 | 1534 |
1523 } // namespace content | 1535 } // namespace content |
OLD | NEW |