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

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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/sync_file_system/drive_backend/metadata_database_index.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc
index e2a092ee3d168a9c54ca1743993d7df2a9386a4e..ab2b8e485a596e08b5e8c95d55e1a6e6b379971b 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc
@@ -98,7 +98,7 @@ void ReadDatabaseContents(LevelDBWrapper* db, DatabaseContents* contents) {
continue;
}
- contents->file_metadata.push_back(metadata.release());
+ contents->file_metadata.push_back(std::move(metadata));
continue;
}
@@ -117,7 +117,7 @@ void ReadDatabaseContents(LevelDBWrapper* db, DatabaseContents* contents) {
"Failed to parse a Tracker");
continue;
}
- contents->file_trackers.push_back(tracker.release());
+ contents->file_trackers.push_back(std::move(tracker));
continue;
}
}
@@ -168,12 +168,12 @@ void RemoveUnreachableItemsFromDB(DatabaseContents* contents,
}
// Delete all unreachable trackers.
- ScopedVector<FileTracker> reachable_trackers;
+ std::vector<std::unique_ptr<FileTracker>> reachable_trackers;
for (size_t i = 0; i < contents->file_trackers.size(); ++i) {
- FileTracker* tracker = contents->file_trackers[i];
+ FileTracker* tracker = contents->file_trackers[i].get();
if (base::ContainsKey(visited_trackers, tracker->tracker_id())) {
- reachable_trackers.push_back(tracker);
- contents->file_trackers[i] = nullptr;
+ reachable_trackers.push_back(base::WrapUnique(tracker));
+ contents->file_trackers[i].release();
Avi (use Gerrit) 2017/01/09 17:18:29 Wrapping an existing unique_ptr and then releasing
leonhsl(Using Gerrit) 2017/01/10 04:39:36 Done.
} else {
PutFileTrackerDeletionToDB(tracker->tracker_id(), db);
}
@@ -186,12 +186,12 @@ void RemoveUnreachableItemsFromDB(DatabaseContents* contents,
referred_file_ids.insert(contents->file_trackers[i]->file_id());
// Delete all unreferred metadata.
- ScopedVector<FileMetadata> referred_file_metadata;
+ std::vector<std::unique_ptr<FileMetadata>> referred_file_metadata;
for (size_t i = 0; i < contents->file_metadata.size(); ++i) {
- FileMetadata* metadata = contents->file_metadata[i];
+ FileMetadata* metadata = contents->file_metadata[i].get();
if (base::ContainsKey(referred_file_ids, metadata->file_id())) {
- referred_file_metadata.push_back(metadata);
- contents->file_metadata[i] = nullptr;
+ referred_file_metadata.push_back(base::WrapUnique(metadata));
+ contents->file_metadata[i].release();
Avi (use Gerrit) 2017/01/09 17:18:29 Same here.
leonhsl(Using Gerrit) 2017/01/10 04:39:36 Done.
} else {
PutFileMetadataDeletionToDB(metadata->file_id(), db);
}
@@ -238,12 +238,12 @@ void MetadataDatabaseIndex::Initialize(
service_metadata_ = std::move(service_metadata);
for (size_t i = 0; i < contents->file_metadata.size(); ++i)
- StoreFileMetadata(base::WrapUnique(contents->file_metadata[i]));
- contents->file_metadata.weak_clear();
+ StoreFileMetadata(std::move(contents->file_metadata[i]));
+ contents->file_metadata.clear();
for (size_t i = 0; i < contents->file_trackers.size(); ++i)
- StoreFileTracker(base::WrapUnique(contents->file_trackers[i]));
- contents->file_trackers.weak_clear();
+ StoreFileTracker(std::move(contents->file_trackers[i]));
+ contents->file_trackers.clear();
UMA_HISTOGRAM_COUNTS("SyncFileSystem.MetadataNumber", metadata_by_id_.size());
UMA_HISTOGRAM_COUNTS("SyncFileSystem.TrackerNumber", tracker_by_id_.size());

Powered by Google App Engine
This is Rietveld 408576698