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

Unified Diff: device/bluetooth/bluetooth_adapter_win.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/bluetooth_adapter_win.cc
diff --git a/device/bluetooth/bluetooth_adapter_win.cc b/device/bluetooth/bluetooth_adapter_win.cc
index 1bacaacf9b369bc692758ba72d4a1a483fdca2f0..7f26f49ed5728052010711cc3951475ac431a8ca 100644
--- a/device/bluetooth/bluetooth_adapter_win.cc
+++ b/device/bluetooth/bluetooth_adapter_win.cc
@@ -227,7 +227,8 @@ void BluetoothAdapterWin::AdapterStateChanged(
}
void BluetoothAdapterWin::DevicesPolled(
- const ScopedVector<BluetoothTaskManagerWin::DeviceState>& devices) {
+ const std::vector<std::unique_ptr<BluetoothTaskManagerWin::DeviceState>>&
+ devices) {
DCHECK(thread_checker_.CalledOnValidThread());
// We are receiving a new list of all devices known to the system. Merge this
@@ -243,11 +244,8 @@ void BluetoothAdapterWin::DevicesPolled(
}
DeviceAddressSet new_devices;
- for (ScopedVector<BluetoothTaskManagerWin::DeviceState>::const_iterator iter =
- devices.begin();
- iter != devices.end();
- ++iter) {
- new_devices.insert((*iter)->address);
+ for (auto& device : devices) {
+ new_devices.insert(device->address);
}
// Process device removal first
@@ -267,27 +265,22 @@ void BluetoothAdapterWin::DevicesPolled(
base::STLSetDifference<DeviceAddressSet>(new_devices, known_devices);
DeviceAddressSet changed_devices =
base::STLSetIntersection<DeviceAddressSet>(known_devices, new_devices);
- for (ScopedVector<BluetoothTaskManagerWin::DeviceState>::const_iterator iter =
- devices.begin();
- iter != devices.end();
- ++iter) {
- BluetoothTaskManagerWin::DeviceState* device_state = (*iter);
- if (added_devices.find(device_state->address) != added_devices.end()) {
+ for (auto& device : devices) {
+ if (added_devices.find(device->address) != added_devices.end()) {
BluetoothDeviceWin* device_win =
- new BluetoothDeviceWin(this, *device_state, ui_task_runner_,
- socket_thread_, NULL, net::NetLogSource());
- devices_.set(device_state->address,
+ new BluetoothDeviceWin(this, device, ui_task_runner_, socket_thread_,
+ NULL, net::NetLogSource());
+ devices_.set(device->address,
std::unique_ptr<BluetoothDevice>(device_win));
for (auto& observer : observers_)
observer.DeviceAdded(this, device_win);
- } else if (changed_devices.find(device_state->address) !=
- changed_devices.end()) {
- DevicesMap::const_iterator iter = devices_.find(device_state->address);
+ } else if (changed_devices.find(device->address) != changed_devices.end()) {
+ DevicesMap::const_iterator iter = devices_.find(device->address);
DCHECK(iter != devices_.end());
BluetoothDeviceWin* device_win =
static_cast<BluetoothDeviceWin*>(iter->second);
- if (!device_win->IsEqual(*device_state)) {
- device_win->Update(*device_state);
+ if (!device_win->IsEqual(*device)) {
+ device_win->Update(*device);
for (auto& observer : observers_)
observer.DeviceChanged(this, device_win);
}
@@ -296,7 +289,7 @@ void BluetoothAdapterWin::DevicesPolled(
// we may simulate characteristic, descriptor and secondary GATT service
// after device has been initialized.
if (force_update_device_for_test_)
- device_win->Update(*device_state);
+ device_win->Update(*device);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698