Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2650)

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Mac bustage Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 10f763901184d4b89d06938545d72d305cd030cd..65efd66d2eaf981ed9c9dd686ff50a3e21098773 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -502,11 +502,16 @@ void BluetoothAdapterMac::ClassicDeviceAdded(IOBluetoothDevice* device) {
}
device_classic = new BluetoothClassicDeviceMac(this, device);
- devices_.set(device_address, base::WrapUnique(device_classic));
VLOG(1) << "Adding new classic device: " << device_classic->GetAddress();
+ auto insertion = devices_.insert(
+ std::make_pair(device_address, std::move(device_classic)));
+ if (!insertion.second) {
+ VLOG(1) << "Insertion of device_classic failed.";
+ return;
+ }
for (auto& observer : observers_)
- observer.DeviceAdded(this, device_classic);
+ observer.DeviceAdded(this, insertion.first->second.get());
}
void BluetoothAdapterMac::LowEnergyDeviceUpdated(
@@ -566,9 +571,15 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
if (is_new_device) {
std::string device_address =
BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
- devices_.add(device_address, std::unique_ptr<BluetoothDevice>(device_mac));
+ auto insertion =
+ devices_.insert(std::make_pair(device_address, std::move(device_mac)));
+
+ if (!insertion.second) {
+ VLOG(1) << "Insertion of device_mac failed.";
+ return;
+ }
for (auto& observer : observers_)
- observer.DeviceAdded(this, device_mac);
+ observer.DeviceAdded(this, insertion.first->second.get());
} else {
for (auto& observer : observers_)
observer.DeviceChanged(this, device_mac);
@@ -620,8 +631,7 @@ BluetoothAdapterMac::RetrieveGattConnectedDevicesWithService(
device_mac = new BluetoothLowEnergyDeviceMac(this, peripheral);
std::string device_address =
BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
- devices_.add(device_address,
- std::unique_ptr<BluetoothDevice>(device_mac));
+ devices_.insert(std::make_pair(device_address, std::move(device_mac)));
for (auto& observer : observers_) {
observer.DeviceAdded(this, device_mac);
}
@@ -698,7 +708,7 @@ BluetoothAdapterMac::GetBluetoothLowEnergyDeviceMac(CBPeripheral* peripheral) {
if (iter == devices_.end()) {
return nil;
}
- return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second);
+ return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second.get());
}
bool BluetoothAdapterMac::DoesCollideWithKnownDevice(

Powered by Google App Engine
This is Rietveld 408576698