Chromium Code Reviews| Index: chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc |
| diff --git a/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc b/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc |
| index 602195e2b338471bf0f5fa42d05a00e3ce9918a7..aa6b4ebf7fedcaaac7b267ada5aa728fb72e1e5a 100644 |
| --- a/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc |
| +++ b/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc |
| @@ -6,7 +6,6 @@ |
| #include <memory> |
| -#include "base/memory/scoped_vector.h" |
| #include "base/rand_util.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/values.h" |
| @@ -69,16 +68,15 @@ std::string GetRandomId( |
| } |
| void CreateMappingForUnmappedDevices( |
| - std::vector<DeviceInfo*>* device_info, |
| + const std::vector<std::unique_ptr<DeviceInfo>>& device_info, |
| base::DictionaryValue* value) { |
| - for (unsigned int i = 0; i < device_info->size(); ++i) { |
| - DeviceInfo* device = (*device_info)[i]; |
| + for (const std::unique_ptr<DeviceInfo>& device : device_info) { |
| std::string local_id = GetPublicIdFromGUID(*value, |
| device->guid()); |
| // If the device does not have a local id, set one. |
| if (local_id.empty()) { |
| - local_id = GetRandomId(*value, device_info->size()); |
| + local_id = GetRandomId(*value, device_info.size()); |
| value->SetString(local_id, device->guid()); |
| } |
| device->set_public_id(local_id); |
| @@ -91,14 +89,12 @@ std::unique_ptr<DeviceInfo> GetDeviceInfoForClientId( |
| Profile* profile) { |
| DCHECK(crx_file::id_util::IdIsValid(extension_id)) << extension_id |
| << " is not valid"; |
| - ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id, |
| - profile); |
| - for (ScopedVector<DeviceInfo>::iterator it = devices.begin(); |
| - it != devices.end(); |
| - ++it) { |
| + std::vector<std::unique_ptr<DeviceInfo>> devices = |
| + GetAllSignedInDevices(extension_id, profile); |
| + for (std::vector<std::unique_ptr<DeviceInfo>>::iterator it = devices.begin(); |
| + it != devices.end(); ++it) { |
|
asargent_no_longer_on_chrome
2016/09/06 22:12:40
consider shortening this to:
for (auto it : devic
lazyboy
2016/09/06 23:49:38
Done.
|
| if ((*it)->guid() == client_id) { |
| - std::unique_ptr<DeviceInfo> device(*it); |
| - devices.weak_erase(it); |
| + std::unique_ptr<DeviceInfo> device = std::move(*it); |
| return device; |
| } |
| } |