Chromium Code Reviews| 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_mac.h" | 5 #include "device/bluetooth/bluetooth_adapter_mac.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 CBAdvertisementDataServiceDataKey : [NSDictionary dictionary], | 77 CBAdvertisementDataServiceDataKey : [NSDictionary dictionary], |
| 78 }; | 78 }; |
| 79 return [advertisement_data retain]; | 79 return [advertisement_data retain]; |
| 80 } | 80 } |
| 81 | 81 |
| 82 std::string GetHashAddress(CBPeripheral* peripheral) { | 82 std::string GetHashAddress(CBPeripheral* peripheral) { |
| 83 return BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); | 83 return BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void AddLowEnergyDevice(BluetoothLowEnergyDeviceMac* device) { | 86 void AddLowEnergyDevice(BluetoothLowEnergyDeviceMac* device) { |
| 87 adapter_mac_->devices_.set(device->GetAddress(), | 87 adapter_mac_->devices_.insert( |
| 88 std::unique_ptr<BluetoothDevice>(device)); | 88 std::make_pair(device->GetAddress(), std::move(device))); |
|
Reilly Grant (use Gerrit)
2016/12/21 22:25:13
When the intent is to replace the device (as set d
dougt
2016/12/22 01:18:02
This works in places where we don't have to immedi
| |
| 89 } | 89 } |
| 90 | 90 |
| 91 int NumDevices() { return adapter_mac_->devices_.size(); } | 91 int NumDevices() { return adapter_mac_->devices_.size(); } |
| 92 | 92 |
| 93 bool DevicePresent(CBPeripheral* peripheral) { | 93 bool DevicePresent(CBPeripheral* peripheral) { |
| 94 BluetoothDevice* device = adapter_mac_->GetDevice( | 94 BluetoothDevice* device = adapter_mac_->GetDevice( |
| 95 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral)); | 95 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral)); |
| 96 return (device != NULL); | 96 return (device != NULL); |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 base::scoped_nsobject<NSDictionary> advertisement_data(AdvertisementData()); | 253 base::scoped_nsobject<NSDictionary> advertisement_data(AdvertisementData()); |
| 254 | 254 |
| 255 EXPECT_EQ(0, NumDevices()); | 255 EXPECT_EQ(0, NumDevices()); |
| 256 EXPECT_FALSE(DevicePresent(mock_peripheral)); | 256 EXPECT_FALSE(DevicePresent(mock_peripheral)); |
| 257 LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi); | 257 LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi); |
| 258 EXPECT_EQ(1, NumDevices()); | 258 EXPECT_EQ(1, NumDevices()); |
| 259 EXPECT_TRUE(DevicePresent(mock_peripheral)); | 259 EXPECT_TRUE(DevicePresent(mock_peripheral)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace device | 262 } // namespace device |
| OLD | NEW |