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

Unified Diff: device/bluetooth/test/mock_bluetooth_adapter.cc

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: 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/test/mock_bluetooth_adapter.cc
diff --git a/device/bluetooth/test/mock_bluetooth_adapter.cc b/device/bluetooth/test/mock_bluetooth_adapter.cc
index 2667650f40bf97e3f6678254e9593f482b1f128c..0d43faba459e0a53742611533e74bcc0edbc5d7b 100644
--- a/device/bluetooth/test/mock_bluetooth_adapter.cc
+++ b/device/bluetooth/test/mock_bluetooth_adapter.cc
@@ -68,29 +68,32 @@ void MockBluetoothAdapter::AddMockDevice(
std::unique_ptr<MockBluetoothDevice> MockBluetoothAdapter::RemoveMockDevice(
const std::string& address) {
- for (auto it = mock_devices_.begin(); it != mock_devices_.end(); ++it) {
- if ((*it)->GetAddress() != address) {
+ for (auto& device : mock_devices_) {
+ if (device->GetAddress() != address) {
continue;
}
- std::unique_ptr<MockBluetoothDevice> removed_device(*it);
- mock_devices_.weak_erase(it);
- return removed_device;
+ std::unique_ptr<MockBluetoothDevice> removed_device = std::move(device);
+ auto it = std::find(mock_devices_.begin(), mock_devices_.end(), device);
+ if (it != mock_devices_.end()) {
+ mock_devices_.erase(it);
+ return removed_device;
+ }
}
return nullptr;
}
BluetoothAdapter::ConstDeviceList MockBluetoothAdapter::GetConstMockDevices() {
BluetoothAdapter::ConstDeviceList devices;
- for (auto* it : mock_devices_) {
- devices.push_back(it);
+ for (auto& device : mock_devices_) {
+ devices.push_back(device.get());
}
return devices;
}
BluetoothAdapter::DeviceList MockBluetoothAdapter::GetMockDevices() {
BluetoothAdapter::DeviceList devices;
- for (auto* it : mock_devices_) {
- devices.push_back(it);
+ for (auto& device : mock_devices_) {
+ devices.push_back(device.get());
}
return devices;
}

Powered by Google App Engine
This is Rietveld 408576698