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

Unified Diff: device/bluetooth/bluetooth_adapter_android.cc

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map 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_android.cc
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index 41228bb635bae3ac24c26c8b50bb22d539a22013..2866d2e7885fd1c9ba11aa76afd63576dde9f1a1 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -197,7 +197,7 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
device_android = device_android_owner.get();
} else {
// Existing device.
- device_android = static_cast<BluetoothDeviceAndroid*>(iter->second);
+ device_android = static_cast<BluetoothDeviceAndroid*>(iter->second.get());
}
DCHECK(device_android);
@@ -219,9 +219,13 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
tx_power == INT32_MIN ? nullptr : &clamped_tx_power);
if (is_new_device) {
- devices_.add(device_address, std::move(device_android_owner));
+ auto insertion = devices_.insert(
+ std::make_pair(device_address, std::move(device_android_owner)));
+ if (!insertion.second) {
+ VLOG(1) << "Insertion of device failed.";
+ }
Reilly Grant (use Gerrit) 2016/12/21 22:25:13 I would make the loop below contingent on insertio
dougt 2016/12/22 01:18:02 Done.
for (auto& observer : observers_)
- observer.DeviceAdded(this, device_android);
+ observer.DeviceAdded(this, insertion.first->second.get());
} else {
for (auto& observer : observers_)
observer.DeviceChanged(this, device_android);

Powered by Google App Engine
This is Rietveld 408576698