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

Unified Diff: device/bluetooth/bluetooth_adapter.cc

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.cc
diff --git a/device/bluetooth/bluetooth_adapter.cc b/device/bluetooth/bluetooth_adapter.cc
index 382928e264429d59a25a932508c8b19c03a73b7c..ce2556dee06b72b4fefe6dd1ac9300b789234cc6 100644
--- a/device/bluetooth/bluetooth_adapter.cc
+++ b/device/bluetooth/bluetooth_adapter.cc
@@ -110,10 +110,8 @@ BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() {
BluetoothAdapter::ConstDeviceList BluetoothAdapter::GetDevices() const {
ConstDeviceList devices;
- for (DevicesMap::const_iterator iter = devices_.begin();
- iter != devices_.end();
- ++iter)
- devices.push_back(iter->second);
+ for (auto& device : devices_)
+ devices.push_back(device.second.get());
return devices;
}
@@ -132,7 +130,7 @@ const BluetoothDevice* BluetoothAdapter::GetDevice(
DevicesMap::const_iterator iter = devices_.find(canonicalized_address);
if (iter != devices_.end())
- return iter->second;
+ return iter->second.get();
return nullptr;
}
@@ -377,7 +375,7 @@ BluetoothAdapter::GetMergedDiscoveryFilterHelper(
void BluetoothAdapter::RemoveTimedOutDevices() {
for (DevicesMap::iterator it = devices_.begin(); it != devices_.end();) {
- BluetoothDevice* device = it->second;
+ BluetoothDevice* device = it->second.get();
if (device->IsPaired() || device->IsConnected() ||
device->IsGattConnected()) {
++it;
@@ -400,8 +398,8 @@ void BluetoothAdapter::RemoveTimedOutDevices() {
VLOG(1) << "Removing device: " << device->GetAddress();
DevicesMap::iterator next = it;
next++;
- std::unique_ptr<BluetoothDevice> removed_device =
- devices_.take_and_erase(it);
+ std::unique_ptr<BluetoothDevice> removed_device = std::move(it->second);
+ devices_.erase(it);
it = next;
for (auto& observer : observers_)

Powered by Google App Engine
This is Rietveld 408576698