OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 const dbus::ObjectPath& object_path, | 434 const dbus::ObjectPath& object_path, |
435 const std::string& property_name) { | 435 const std::string& property_name) { |
436 BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); | 436 BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); |
437 if (!device_chromeos) | 437 if (!device_chromeos) |
438 return; | 438 return; |
439 | 439 |
440 BluetoothDeviceClient::Properties* properties = | 440 BluetoothDeviceClient::Properties* properties = |
441 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> | 441 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
442 GetProperties(object_path); | 442 GetProperties(object_path); |
443 | 443 |
444 if (property_name == properties->address.name()) { | |
445 for (DevicesMap::const_iterator iter = devices_.begin(); | |
446 iter != devices_.end(); ++iter) { | |
armansito
2015/09/25 18:42:30
nit: for (const auto& iter : devices_)
jpawlowski1
2015/09/25 19:25:45
I need iterator, want to call erase() with iterato
| |
447 if (iter->second->GetAddress() == device_chromeos->GetAddress()) { | |
448 std::string old_address = iter->first; | |
449 VLOG(1) << "Device changed address, old: " << old_address | |
450 << " new: " << device_chromeos->GetAddress(); | |
451 devices_.erase(iter); | |
452 | |
453 DCHECK(devices_.find(device_chromeos->GetAddress()) == devices_.end()); | |
454 devices_[device_chromeos->GetAddress()] = device_chromeos; | |
455 NotifyDeviceAddressChanged(device_chromeos, old_address); | |
456 break; | |
457 } | |
458 } | |
459 } | |
460 | |
444 if (property_name == properties->bluetooth_class.name() || | 461 if (property_name == properties->bluetooth_class.name() || |
445 property_name == properties->address.name() || | 462 property_name == properties->address.name() || |
446 property_name == properties->alias.name() || | 463 property_name == properties->alias.name() || |
447 property_name == properties->paired.name() || | 464 property_name == properties->paired.name() || |
448 property_name == properties->trusted.name() || | 465 property_name == properties->trusted.name() || |
449 property_name == properties->connected.name() || | 466 property_name == properties->connected.name() || |
450 property_name == properties->uuids.name() || | 467 property_name == properties->uuids.name() || |
451 property_name == properties->rssi.name() || | 468 property_name == properties->rssi.name() || |
452 property_name == properties->tx_power.name()) { | 469 property_name == properties->tx_power.name()) { |
453 NotifyDeviceChanged(device_chromeos); | 470 NotifyDeviceChanged(device_chromeos); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 | 879 |
863 void BluetoothAdapterChromeOS::NotifyDeviceChanged( | 880 void BluetoothAdapterChromeOS::NotifyDeviceChanged( |
864 BluetoothDeviceChromeOS* device) { | 881 BluetoothDeviceChromeOS* device) { |
865 DCHECK(device); | 882 DCHECK(device); |
866 DCHECK(device->adapter_ == this); | 883 DCHECK(device->adapter_ == this); |
867 | 884 |
868 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | 885 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
869 DeviceChanged(this, device)); | 886 DeviceChanged(this, device)); |
870 } | 887 } |
871 | 888 |
889 void BluetoothAdapterChromeOS::NotifyDeviceAddressChanged( | |
890 BluetoothDeviceChromeOS* device, | |
891 const std::string& old_address) { | |
892 DCHECK(device->adapter_ == this); | |
893 | |
894 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | |
895 DeviceAddressChanged(this, device, old_address)); | |
896 } | |
897 | |
872 void BluetoothAdapterChromeOS::NotifyGattServiceAdded( | 898 void BluetoothAdapterChromeOS::NotifyGattServiceAdded( |
873 BluetoothRemoteGattServiceChromeOS* service) { | 899 BluetoothRemoteGattServiceChromeOS* service) { |
874 DCHECK_EQ(service->GetAdapter(), this); | 900 DCHECK_EQ(service->GetAdapter(), this); |
875 DCHECK_EQ( | 901 DCHECK_EQ( |
876 static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_, | 902 static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_, |
877 this); | 903 this); |
878 | 904 |
879 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, | 905 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, |
880 observers_, | 906 observers_, |
881 GattServiceAdded(this, service->GetDevice(), service)); | 907 GattServiceAdded(this, service->GetDevice(), service)); |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1465 | 1491 |
1466 // If the queued request resulted in a pending call, then let it | 1492 // If the queued request resulted in a pending call, then let it |
1467 // asynchonously process the remaining queued requests once the pending | 1493 // asynchonously process the remaining queued requests once the pending |
1468 // call returns. | 1494 // call returns. |
1469 if (discovery_request_pending_) | 1495 if (discovery_request_pending_) |
1470 return; | 1496 return; |
1471 } | 1497 } |
1472 } | 1498 } |
1473 | 1499 |
1474 } // namespace chromeos | 1500 } // namespace chromeos |
OLD | NEW |