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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 FileDetails* details = file->mutable_details(); 455 FileDetails* details = file->mutable_details();
456 details->set_md5( 456 details->set_md5(
457 "md5_value_" + base::Int64ToString(next_md5_sequence_number_++)); 457 "md5_value_" + base::Int64ToString(next_md5_sequence_number_++));
458 details->set_change_id(++current_change_id_); 458 details->set_change_id(++current_change_id_);
459 } 459 }
460 460
461 void ApplyNoopChangeToMetadata(FileMetadata* file) { 461 void ApplyNoopChangeToMetadata(FileMetadata* file) {
462 file->mutable_details()->set_change_id(++current_change_id_); 462 file->mutable_details()->set_change_id(++current_change_id_);
463 } 463 }
464 464
465 void PushToChangeList(std::unique_ptr<google_apis::ChangeResource> change, 465 void PushToChangeList(
466 ScopedVector<google_apis::ChangeResource>* changes) { 466 std::unique_ptr<google_apis::ChangeResource> change,
467 changes->push_back(change.release()); 467 std::vector<std::unique_ptr<google_apis::ChangeResource>>* changes) {
468 changes->push_back(std::move(change));
468 } 469 }
469 470
470 leveldb::Status PutFileToDB(LevelDBWrapper* db, const FileMetadata& file) { 471 leveldb::Status PutFileToDB(LevelDBWrapper* db, const FileMetadata& file) {
471 PutFileMetadataToDB(file, db); 472 PutFileMetadataToDB(file, db);
472 return db->Commit(); 473 return db->Commit();
473 } 474 }
474 475
475 leveldb::Status PutTrackerToDB(LevelDBWrapper* db, 476 leveldb::Status PutTrackerToDB(LevelDBWrapper* db,
476 const FileTracker& tracker) { 477 const FileTracker& tracker) {
477 PutFileTrackerToDB(tracker, db); 478 PutFileTrackerToDB(tracker, db);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 580
580 SyncStatusCode EnableApp(const std::string& app_id) { 581 SyncStatusCode EnableApp(const std::string& app_id) {
581 return metadata_database_->EnableApp(app_id); 582 return metadata_database_->EnableApp(app_id);
582 } 583 }
583 584
584 SyncStatusCode UnregisterApp(const std::string& app_id) { 585 SyncStatusCode UnregisterApp(const std::string& app_id) {
585 return metadata_database_->UnregisterApp(app_id); 586 return metadata_database_->UnregisterApp(app_id);
586 } 587 }
587 588
588 SyncStatusCode UpdateByChangeList( 589 SyncStatusCode UpdateByChangeList(
589 ScopedVector<google_apis::ChangeResource> changes) { 590 std::vector<std::unique_ptr<google_apis::ChangeResource>> changes) {
590 return metadata_database_->UpdateByChangeList(current_change_id_, 591 return metadata_database_->UpdateByChangeList(current_change_id_,
591 std::move(changes)); 592 std::move(changes));
592 } 593 }
593 594
594 SyncStatusCode PopulateFolder(const std::string& folder_id, 595 SyncStatusCode PopulateFolder(const std::string& folder_id,
595 const FileIDList& listed_children) { 596 const FileIDList& listed_children) {
596 return metadata_database_->PopulateFolderByChildList( 597 return metadata_database_->PopulateFolderByChildList(
597 folder_id, listed_children); 598 folder_id, listed_children);
598 } 599 }
599 600
600 SyncStatusCode UpdateTracker(const FileTracker& tracker) { 601 SyncStatusCode UpdateTracker(const FileTracker& tracker) {
601 return metadata_database_->UpdateTracker( 602 return metadata_database_->UpdateTracker(
602 tracker.tracker_id(), tracker.synced_details()); 603 tracker.tracker_id(), tracker.synced_details());
603 } 604 }
604 605
605 SyncStatusCode PopulateInitialData( 606 SyncStatusCode PopulateInitialData(
606 int64_t largest_change_id, 607 int64_t largest_change_id,
607 const google_apis::FileResource& sync_root_folder, 608 const google_apis::FileResource& sync_root_folder,
608 const ScopedVector<google_apis::FileResource>& app_root_folders) { 609 const std::vector<std::unique_ptr<google_apis::FileResource>>&
610 app_root_folders) {
609 return metadata_database_->PopulateInitialData( 611 return metadata_database_->PopulateInitialData(
610 largest_change_id, sync_root_folder, app_root_folders); 612 largest_change_id, sync_root_folder, app_root_folders);
611 } 613 }
612 614
613 void ResetTrackerID(FileTracker* tracker) { 615 void ResetTrackerID(FileTracker* tracker) {
614 tracker->set_tracker_id(GetTrackerIDByFileID(tracker->file_id())); 616 tracker->set_tracker_id(GetTrackerIDByFileID(tracker->file_id()));
615 } 617 }
616 618
617 int64_t current_change_id() const { return current_change_id_; } 619 int64_t current_change_id() const { return current_change_id_; }
618 620
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase()); 910 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
909 911
910 ApplyRenameChangeToMetadata("renamed", &renamed_file.metadata); 912 ApplyRenameChangeToMetadata("renamed", &renamed_file.metadata);
911 ApplyReorganizeChangeToMetadata(folder.metadata.file_id(), 913 ApplyReorganizeChangeToMetadata(folder.metadata.file_id(),
912 &reorganized_file.metadata); 914 &reorganized_file.metadata);
913 ApplyContentChangeToMetadata(&updated_file.metadata); 915 ApplyContentChangeToMetadata(&updated_file.metadata);
914 916
915 // Update change ID. 917 // Update change ID.
916 ApplyNoopChangeToMetadata(&noop_file.metadata); 918 ApplyNoopChangeToMetadata(&noop_file.metadata);
917 919
918 ScopedVector<google_apis::ChangeResource> changes; 920 std::vector<std::unique_ptr<google_apis::ChangeResource>> changes;
919 PushToChangeList( 921 PushToChangeList(
920 CreateChangeResourceFromMetadata(renamed_file.metadata), &changes); 922 CreateChangeResourceFromMetadata(renamed_file.metadata), &changes);
921 PushToChangeList( 923 PushToChangeList(
922 CreateChangeResourceFromMetadata(reorganized_file.metadata), &changes); 924 CreateChangeResourceFromMetadata(reorganized_file.metadata), &changes);
923 PushToChangeList( 925 PushToChangeList(
924 CreateChangeResourceFromMetadata(updated_file.metadata), &changes); 926 CreateChangeResourceFromMetadata(updated_file.metadata), &changes);
925 PushToChangeList( 927 PushToChangeList(
926 CreateChangeResourceFromMetadata(noop_file.metadata), &changes); 928 CreateChangeResourceFromMetadata(noop_file.metadata), &changes);
927 PushToChangeList( 929 PushToChangeList(
928 CreateChangeResourceFromMetadata(new_file.metadata), &changes); 930 CreateChangeResourceFromMetadata(new_file.metadata), &changes);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1114
1113 const TrackedFile* tracked_files[] = { 1115 const TrackedFile* tracked_files[] = {
1114 &sync_root, &app_root 1116 &sync_root, &app_root
1115 }; 1117 };
1116 1118
1117 std::unique_ptr<google_apis::FileResource> sync_root_folder( 1119 std::unique_ptr<google_apis::FileResource> sync_root_folder(
1118 CreateFileResourceFromMetadata(sync_root.metadata)); 1120 CreateFileResourceFromMetadata(sync_root.metadata));
1119 std::unique_ptr<google_apis::FileResource> app_root_folder( 1121 std::unique_ptr<google_apis::FileResource> app_root_folder(
1120 CreateFileResourceFromMetadata(app_root.metadata)); 1122 CreateFileResourceFromMetadata(app_root.metadata));
1121 1123
1122 ScopedVector<google_apis::FileResource> app_root_folders; 1124 std::vector<std::unique_ptr<google_apis::FileResource>> app_root_folders;
1123 app_root_folders.push_back(app_root_folder.release()); 1125 app_root_folders.push_back(std::move(app_root_folder));
1124 1126
1125 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase()); 1127 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
1126 EXPECT_EQ(SYNC_STATUS_OK, PopulateInitialData( 1128 EXPECT_EQ(SYNC_STATUS_OK, PopulateInitialData(
1127 current_change_id(), 1129 current_change_id(),
1128 *sync_root_folder, 1130 *sync_root_folder,
1129 app_root_folders)); 1131 app_root_folders));
1130 1132
1131 ResetTrackerID(&sync_root.tracker); 1133 ResetTrackerID(&sync_root.tracker);
1132 ResetTrackerID(&app_root.tracker); 1134 ResetTrackerID(&app_root.tracker);
1133 app_root.tracker.set_parent_tracker_id(sync_root.tracker.tracker_id()); 1135 app_root.tracker.set_parent_tracker_id(sync_root.tracker.tracker_id());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 EXPECT_TRUE(file->HasKey("details")); 1167 EXPECT_TRUE(file->HasKey("details"));
1166 1168
1167 ASSERT_TRUE(files->GetDictionary(1, &file)); 1169 ASSERT_TRUE(files->GetDictionary(1, &file));
1168 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0"); 1170 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0");
1169 EXPECT_TRUE(file->GetString("type", &str) && str == "file"); 1171 EXPECT_TRUE(file->GetString("type", &str) && str == "file");
1170 EXPECT_TRUE(file->HasKey("details")); 1172 EXPECT_TRUE(file->HasKey("details"));
1171 } 1173 }
1172 1174
1173 } // namespace drive_backend 1175 } // namespace drive_backend
1174 } // namespace sync_file_system 1176 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698