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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database.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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 return !index_->IsSyncRootRevalidated(); 615 return !index_->IsSyncRootRevalidated();
616 } 616 }
617 617
618 bool MetadataDatabase::HasSyncRoot() const { 618 bool MetadataDatabase::HasSyncRoot() const {
619 return index_->GetSyncRootTrackerID() != kInvalidTrackerID; 619 return index_->GetSyncRootTrackerID() != kInvalidTrackerID;
620 } 620 }
621 621
622 SyncStatusCode MetadataDatabase::PopulateInitialData( 622 SyncStatusCode MetadataDatabase::PopulateInitialData(
623 int64_t largest_change_id, 623 int64_t largest_change_id,
624 const google_apis::FileResource& sync_root_folder, 624 const google_apis::FileResource& sync_root_folder,
625 const ScopedVector<google_apis::FileResource>& app_root_folders) { 625 const std::vector<std::unique_ptr<google_apis::FileResource>>&
626 app_root_folders) {
626 index_->SetLargestChangeID(largest_change_id); 627 index_->SetLargestChangeID(largest_change_id);
627 UpdateLargestKnownChangeID(largest_change_id); 628 UpdateLargestKnownChangeID(largest_change_id);
628 629
629 AttachSyncRoot(sync_root_folder); 630 AttachSyncRoot(sync_root_folder);
630 for (size_t i = 0; i < app_root_folders.size(); ++i) 631 for (size_t i = 0; i < app_root_folders.size(); ++i)
631 AttachInitialAppRoot(*app_root_folders[i]); 632 AttachInitialAppRoot(*app_root_folders[i]);
632 633
633 if (NeedsSyncRootRevalidation()) { 634 if (NeedsSyncRootRevalidation()) {
634 index_->RemoveUnreachableItems(); 635 index_->RemoveUnreachableItems();
635 index_->SetSyncRootRevalidated(); 636 index_->SetSyncRootRevalidated();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 883
883 tracker_out->CopyFrom(tracker); 884 tracker_out->CopyFrom(tracker);
884 *path_out = path_out->Append(components[i]); 885 *path_out = path_out->Append(components[i]);
885 } 886 }
886 887
887 return true; 888 return true;
888 } 889 }
889 890
890 SyncStatusCode MetadataDatabase::UpdateByChangeList( 891 SyncStatusCode MetadataDatabase::UpdateByChangeList(
891 int64_t largest_change_id, 892 int64_t largest_change_id,
892 ScopedVector<google_apis::ChangeResource> changes) { 893 std::vector<std::unique_ptr<google_apis::ChangeResource>> changes) {
893 DCHECK_LE(index_->GetLargestChangeID(), largest_change_id); 894 DCHECK_LE(index_->GetLargestChangeID(), largest_change_id);
894 895
895 for (size_t i = 0; i < changes.size(); ++i) { 896 for (size_t i = 0; i < changes.size(); ++i) {
896 const google_apis::ChangeResource& change = *changes[i]; 897 const google_apis::ChangeResource& change = *changes[i];
897 if (HasNewerFileMetadata(change.file_id(), change.change_id())) 898 if (HasNewerFileMetadata(change.file_id(), change.change_id()))
898 continue; 899 continue;
899 900
900 std::unique_ptr<FileMetadata> metadata( 901 std::unique_ptr<FileMetadata> metadata(
901 CreateFileMetadataFromChangeResource(change)); 902 CreateFileMetadataFromChangeResource(change));
902 UpdateByFileMetadata(FROM_HERE, std::move(metadata), 903 UpdateByFileMetadata(FROM_HERE, std::move(metadata),
903 UPDATE_TRACKER_FOR_UNSYNCED_FILE); 904 UPDATE_TRACKER_FOR_UNSYNCED_FILE);
904 } 905 }
905 906
906 UpdateLargestKnownChangeID(largest_change_id); 907 UpdateLargestKnownChangeID(largest_change_id);
907 index_->SetLargestChangeID(largest_change_id); 908 index_->SetLargestChangeID(largest_change_id);
908 return WriteToDatabase(); 909 return WriteToDatabase();
909 } 910 }
910 911
911 SyncStatusCode MetadataDatabase::UpdateByFileResource( 912 SyncStatusCode MetadataDatabase::UpdateByFileResource(
912 const google_apis::FileResource& resource) { 913 const google_apis::FileResource& resource) {
913 std::unique_ptr<FileMetadata> metadata( 914 std::unique_ptr<FileMetadata> metadata(
914 CreateFileMetadataFromFileResource(GetLargestKnownChangeID(), resource)); 915 CreateFileMetadataFromFileResource(GetLargestKnownChangeID(), resource));
915 UpdateByFileMetadata(FROM_HERE, std::move(metadata), 916 UpdateByFileMetadata(FROM_HERE, std::move(metadata),
916 UPDATE_TRACKER_FOR_UNSYNCED_FILE); 917 UPDATE_TRACKER_FOR_UNSYNCED_FILE);
917 return WriteToDatabase(); 918 return WriteToDatabase();
918 } 919 }
919 920
920 SyncStatusCode MetadataDatabase::UpdateByFileResourceList( 921 SyncStatusCode MetadataDatabase::UpdateByFileResourceList(
921 ScopedVector<google_apis::FileResource> resources) { 922 std::vector<std::unique_ptr<google_apis::FileResource>> resources) {
922 for (size_t i = 0; i < resources.size(); ++i) { 923 for (size_t i = 0; i < resources.size(); ++i) {
923 std::unique_ptr<FileMetadata> metadata(CreateFileMetadataFromFileResource( 924 std::unique_ptr<FileMetadata> metadata(CreateFileMetadataFromFileResource(
924 GetLargestKnownChangeID(), *resources[i])); 925 GetLargestKnownChangeID(), *resources[i]));
925 UpdateByFileMetadata(FROM_HERE, std::move(metadata), 926 UpdateByFileMetadata(FROM_HERE, std::move(metadata),
926 UPDATE_TRACKER_FOR_UNSYNCED_FILE); 927 UPDATE_TRACKER_FOR_UNSYNCED_FILE);
927 } 928 }
928 return WriteToDatabase(); 929 return WriteToDatabase();
929 } 930 }
930 931
931 SyncStatusCode MetadataDatabase::UpdateByDeletedRemoteFile( 932 SyncStatusCode MetadataDatabase::UpdateByDeletedRemoteFile(
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 return false; 1805 return false;
1805 1806
1806 if (!parents.empty()) 1807 if (!parents.empty())
1807 return false; 1808 return false;
1808 1809
1809 return true; 1810 return true;
1810 } 1811 }
1811 1812
1812 } // namespace drive_backend 1813 } // namespace drive_backend
1813 } // namespace sync_file_system 1814 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698