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

Unified Diff: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc

Issue 2310683002: Remove most ScopedVector usage from c/b/extensions. (Closed)
Patch Set: remove scoped_vector includes Created 4 years, 3 months 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: chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
index 53e7dd7fb276b396f333c629bcad79c490ba4229..e30c23939d9e1262ded031cc2bb14530b938861f 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
@@ -7,7 +7,6 @@
#include <memory>
#include <utility>
-#include "base/memory/scoped_vector.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -54,12 +53,13 @@ const base::DictionaryValue* GetIdMappingDictionary(
// Helper routine to get all signed in devices. The helper takes in
// the pointers for |DeviceInfoTracker| and |Extensionprefs|. This
// makes it easier to test by passing mock values for these pointers.
-ScopedVector<DeviceInfo> GetAllSignedInDevices(
+std::vector<std::unique_ptr<DeviceInfo>> GetAllSignedInDevices(
const std::string& extension_id,
DeviceInfoTracker* device_tracker,
ExtensionPrefs* extension_prefs) {
DCHECK(device_tracker);
- ScopedVector<DeviceInfo> devices = device_tracker->GetAllDeviceInfo();
+ std::vector<std::unique_ptr<DeviceInfo>> devices =
+ device_tracker->GetAllDeviceInfo();
const base::DictionaryValue* mapping_dictionary = GetIdMappingDictionary(
extension_prefs,
extension_id);
@@ -70,8 +70,7 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
std::unique_ptr<base::DictionaryValue> editable_mapping_dictionary(
mapping_dictionary->DeepCopy());
- CreateMappingForUnmappedDevices(&(devices.get()),
- editable_mapping_dictionary.get());
+ CreateMappingForUnmappedDevices(devices, editable_mapping_dictionary.get());
// Write into |ExtensionPrefs| which will get persisted in disk.
extension_prefs->UpdateExtensionPref(extension_id,
@@ -80,7 +79,7 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
return devices;
}
-ScopedVector<DeviceInfo> GetAllSignedInDevices(
+std::vector<std::unique_ptr<DeviceInfo>> GetAllSignedInDevices(
const std::string& extension_id,
Profile* profile) {
// Get the device tracker and extension prefs pointers
@@ -90,7 +89,7 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
DCHECK(device_tracker);
if (!device_tracker->IsSyncing()) {
// Devices are not sync'ing.
- return ScopedVector<DeviceInfo>();
+ return std::vector<std::unique_ptr<DeviceInfo>>();
}
ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile);
@@ -131,16 +130,13 @@ bool SignedInDevicesGetFunction::RunSync() {
return true;
}
- ScopedVector<DeviceInfo> devices =
+ std::vector<std::unique_ptr<DeviceInfo>> devices =
GetAllSignedInDevices(extension_id(), GetProfile());
std::unique_ptr<base::ListValue> result(new base::ListValue());
- for (ScopedVector<DeviceInfo>::const_iterator it = devices.begin();
- it != devices.end();
- ++it) {
- result->Append((*it)->ToValue());
- }
+ for (const std::unique_ptr<DeviceInfo>& device : devices)
+ result->Append(device->ToValue());
SetResult(std::move(result));
return true;

Powered by Google App Engine
This is Rietveld 408576698