diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-25 09:38:43 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-25 09:38:43 +0000 |
commit | d38aa40b9e68a7ea824a81eac91060dcfff95ef6 (patch) | |
tree | 7792e42e6b64f073dd52aa6792eebe5ffa2d7d09 | |
parent | 5d3d41304756a6af9d7afa7e5dc4e3356f05375c (diff) | |
download | chromium_src-d38aa40b9e68a7ea824a81eac91060dcfff95ef6.zip chromium_src-d38aa40b9e68a7ea824a81eac91060dcfff95ef6.tar.gz chromium_src-d38aa40b9e68a7ea824a81eac91060dcfff95ef6.tar.bz2 |
drive: Add local_id to ResourceEntry
Add local_id to ResourceEntry
Increment DB version
Remove |id| argument from ResourceMetadata::RefreshEntry
Call set_local_id when appropriate
BUG=260514
TEST=unit_tests
Review URL: https://chromiumcodereview.appspot.com/24281012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225167 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 95 insertions, 59 deletions
diff --git a/chrome/browser/chromeos/drive/change_list_processor.cc b/chrome/browser/chromeos/drive/change_list_processor.cc index 7effff1..6718fec 100644 --- a/chrome/browser/chromeos/drive/change_list_processor.cc +++ b/chrome/browser/chromeos/drive/change_list_processor.cc @@ -264,9 +264,11 @@ FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { error = resource_metadata_->RemoveEntry(entry.resource_id()); } else { // Entry exists and needs to be refreshed. - error = resource_metadata_->RefreshEntry(entry.resource_id(), entry); + ResourceEntry new_entry(entry); + new_entry.set_local_id(existing_entry.local_id()); + error = resource_metadata_->RefreshEntry(new_entry); if (error == FILE_ERROR_OK) - UpdateChangedDirs(entry); + UpdateChangedDirs(new_entry); } } else if (error == FILE_ERROR_NOT_FOUND && !entry.deleted()) { // Adding a new entry. @@ -342,7 +344,14 @@ FileError ChangeListProcessor::RefreshDirectory( continue; } - error = resource_metadata->RefreshEntry(it->first, entry); + std::string local_id; + error = resource_metadata->GetIdByResourceId(it->first, &local_id); + if (error == FILE_ERROR_OK) { + ResourceEntry new_entry(entry); + new_entry.set_local_id(local_id); + error = resource_metadata->RefreshEntry(new_entry); + } + if (error == FILE_ERROR_NOT_FOUND) { // If refreshing fails, try adding. std::string local_id; error = resource_metadata->AddEntry(entry, &local_id); @@ -354,8 +363,7 @@ FileError ChangeListProcessor::RefreshDirectory( directory.mutable_directory_specific_info()->set_changestamp( directory_fetch_info.changestamp()); - error = resource_metadata->RefreshEntry(directory_fetch_info.resource_id(), - directory); + error = resource_metadata->RefreshEntry(directory); if (error != FILE_ERROR_OK) return error; @@ -381,7 +389,7 @@ FileError ChangeListProcessor::UpdateRootEntry(int64 largest_changestamp) { // The changestamp should always be updated. root.mutable_directory_specific_info()->set_changestamp(largest_changestamp); - error = resource_metadata_->RefreshEntry(root_local_id, root); + error = resource_metadata_->RefreshEntry(root); if (error != FILE_ERROR_OK) { LOG(WARNING) << "Failed to refresh root directory"; return error; diff --git a/chrome/browser/chromeos/drive/drive.proto b/chrome/browser/chromeos/drive/drive.proto index 9d51409..bab4224 100644 --- a/chrome/browser/chromeos/drive/drive.proto +++ b/chrome/browser/chromeos/drive/drive.proto @@ -75,6 +75,9 @@ message ResourceEntry { // Resource ID of the entry. Guaranteed to be unique. optional string resource_id = 4; + // Local ID of the entry. + optional string local_id = 15; + // Local ID of the parent entry. optional string parent_local_id = 7; diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.cc b/chrome/browser/chromeos/drive/file_system/move_operation.cc index 18e21ff..6d73c6cb 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/move_operation.cc @@ -41,7 +41,7 @@ FileError RenameLocally(internal::ResourceMetadata* metadata, return error; entry.set_title(new_title); - return metadata->RefreshEntry(resource_id, entry); + return metadata->RefreshEntry(entry); } // Applies directory-moving to the local metadata. @@ -55,7 +55,7 @@ FileError MoveDirectoryLocally(internal::ResourceMetadata* metadata, // TODO(hidehiko,hashimoto): Set local id, instead of resource id. entry.set_parent_local_id(parent_resource_id); - return metadata->RefreshEntry(resource_id, entry); + return metadata->RefreshEntry(entry); } } // namespace @@ -192,13 +192,14 @@ void MoveOperation::MoveAfterMoveResource( } // TODO(hashimoto): Resolve local ID before use. crbug.com/260514 + entry.set_local_id(entry.resource_id()); entry.set_parent_local_id(parent_resource_id); base::PostTaskAndReplyWithResult( blocking_task_runner_.get(), FROM_HERE, base::Bind(&internal::ResourceMetadata::RefreshEntry, - base::Unretained(metadata_), entry.resource_id(), entry), + base::Unretained(metadata_), entry), base::Bind(&MoveOperation::MoveAfterRefreshEntry, weak_ptr_factory_.GetWeakPtr(), src_file_path, dest_file_path, callback)); diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc index ca41f7e..f8073f2 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc @@ -92,7 +92,7 @@ FileError UpdateLocalStateAfterUnparent( if (error != FILE_ERROR_OK) return error; entry.set_parent_local_id(util::kDriveOtherDirSpecialResourceId); - return metadata->RefreshEntry(local_id, entry); + return metadata->RefreshEntry(entry); } } // namespace diff --git a/chrome/browser/chromeos/drive/file_system/touch_operation.cc b/chrome/browser/chromeos/drive/file_system/touch_operation.cc index 1ead717..feaa5c0 100644 --- a/chrome/browser/chromeos/drive/file_system/touch_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/touch_operation.cc @@ -53,9 +53,10 @@ FileError RefreshEntry(internal::ResourceMetadata* metadata, if (error != FILE_ERROR_OK) return error; + entry.set_local_id(local_id); entry.set_parent_local_id(parent_local_id); - error = metadata->RefreshEntry(local_id, entry); + error = metadata->RefreshEntry(entry); if (error != FILE_ERROR_OK) return error; diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.cc b/chrome/browser/chromeos/drive/file_system/update_operation.cc index 212ff97..b25ccb6 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/update_operation.cc @@ -83,9 +83,10 @@ FileError UpdateFileLocalState( &parent_local_id); if (error != FILE_ERROR_OK) return error; + entry.set_local_id(local_id); entry.set_parent_local_id(parent_local_id); - error = metadata->RefreshEntry(local_id, entry); + error = metadata->RefreshEntry(entry); if (error != FILE_ERROR_OK) return error; diff --git a/chrome/browser/chromeos/drive/resource_metadata.cc b/chrome/browser/chromeos/drive/resource_metadata.cc index 457eedd..de07b4d 100644 --- a/chrome/browser/chromeos/drive/resource_metadata.cc +++ b/chrome/browser/chromeos/drive/resource_metadata.cc @@ -119,19 +119,20 @@ bool ResourceMetadata::SetUpDefaultEntries() { ResourceEntry root; root.mutable_file_info()->set_is_directory(true); root.set_resource_id(util::kDriveGrandRootSpecialResourceId); + root.set_local_id(util::kDriveGrandRootSpecialResourceId); root.set_title(util::kDriveGrandRootDirName); SetBaseNameFromTitle(&root); - if (!storage_->PutEntry(util::kDriveGrandRootSpecialResourceId, root)) + if (!storage_->PutEntry(root)) return false; } if (!storage_->GetEntry(util::kDriveOtherDirSpecialResourceId, &entry)) { ResourceEntry other_dir; other_dir.mutable_file_info()->set_is_directory(true); other_dir.set_resource_id(util::kDriveOtherDirSpecialResourceId); + other_dir.set_local_id(util::kDriveOtherDirSpecialResourceId); other_dir.set_parent_local_id(util::kDriveGrandRootSpecialResourceId); other_dir.set_title(util::kDriveOtherDirName); - if (!PutEntryUnderDirectory(util::kDriveOtherDirSpecialResourceId, - other_dir)) + if (!PutEntryUnderDirectory(other_dir)) return false; } return true; @@ -178,8 +179,10 @@ FileError ResourceMetadata::AddEntry(const ResourceEntry& entry, // TODO(hashimoto): Generate local ID here. crbug.com/26051 const std::string local_id = entry.resource_id(); + ResourceEntry new_entry(entry); + new_entry.set_local_id(local_id); - if (!PutEntryUnderDirectory(local_id, entry)) + if (!PutEntryUnderDirectory(new_entry)) return FILE_ERROR_FAILED; *out_id = local_id; @@ -313,8 +316,7 @@ FileError ResourceMetadata::ReadDirectoryByPath( return FILE_ERROR_OK; } -FileError ResourceMetadata::RefreshEntry(const std::string& id, - const ResourceEntry& entry) { +FileError ResourceMetadata::RefreshEntry(const ResourceEntry& entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); // TODO(hashimoto): Return an error if the operation will result in having // multiple entries with the same resource ID. @@ -323,7 +325,7 @@ FileError ResourceMetadata::RefreshEntry(const std::string& id, return FILE_ERROR_NO_LOCAL_SPACE; ResourceEntry old_entry; - if (!storage_->GetEntry(id, &old_entry)) + if (!storage_->GetEntry(entry.local_id(), &old_entry)) return FILE_ERROR_NOT_FOUND; if (old_entry.parent_local_id().empty() || // Reject root. @@ -340,7 +342,7 @@ FileError ResourceMetadata::RefreshEntry(const std::string& id, return FILE_ERROR_NOT_A_DIRECTORY; // Remove from the old parent and add it to the new parent with the new data. - if (!PutEntryUnderDirectory(id, entry)) + if (!PutEntryUnderDirectory(entry)) return FILE_ERROR_FAILED; return FILE_ERROR_OK; } @@ -422,9 +424,10 @@ FileError ResourceMetadata::GetIdByResourceId(const std::string& resource_id, return error; } -bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id, - const ResourceEntry& entry) { +bool ResourceMetadata::PutEntryUnderDirectory(const ResourceEntry& entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); + DCHECK(!entry.local_id().empty()); + DCHECK(!entry.parent_local_id().empty()); ResourceEntry updated_entry(entry); @@ -440,7 +443,7 @@ bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id, while (true) { const std::string existing_entry_id = storage_->GetChild(entry.parent_local_id(), new_base_name); - if (existing_entry_id.empty() || existing_entry_id == id) + if (existing_entry_id.empty() || existing_entry_id == entry.local_id()) break; base::FilePath new_path = @@ -454,7 +457,7 @@ bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id, updated_entry.set_base_name(new_base_name); // Add the entry to resource map. - return storage_->PutEntry(id, updated_entry); + return storage_->PutEntry(updated_entry); } bool ResourceMetadata::RemoveEntryRecursively(const std::string& id) { diff --git a/chrome/browser/chromeos/drive/resource_metadata.h b/chrome/browser/chromeos/drive/resource_metadata.h index c88680e..aa40bed 100644 --- a/chrome/browser/chromeos/drive/resource_metadata.h +++ b/chrome/browser/chromeos/drive/resource_metadata.h @@ -103,8 +103,8 @@ class ResourceMetadata { FileError ReadDirectoryByPath(const base::FilePath& file_path, ResourceEntryVector* out_entries); - // Replaces an existing entry whose ID is |id| with |entry|. - FileError RefreshEntry(const std::string& id, const ResourceEntry& entry); + // Replaces an existing entry with the same local ID as |entry|. + FileError RefreshEntry(const ResourceEntry& entry); // Recursively gets directories under the entry pointed to by |id|. void GetSubDirectoriesRecursively(const std::string& id, @@ -143,9 +143,7 @@ class ResourceMetadata { // parent if there is. This method will also do name de-duplication to ensure // that the exposed presentation path does not have naming conflicts. Two // files with the same name "Foo" will be renamed to "Foo (1)" and "Foo (2)". - // |id| is used as the ID of the entry. - bool PutEntryUnderDirectory(const std::string& id, - const ResourceEntry& entry); + bool PutEntryUnderDirectory(const ResourceEntry& entry); // Removes the entry and its descendants. bool RemoveEntryRecursively(const std::string& id); diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.cc b/chrome/browser/chromeos/drive/resource_metadata_storage.cc index 5b2fa28..418f78c 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_storage.cc @@ -405,9 +405,10 @@ int64 ResourceMetadataStorage::GetLargestChangestamp() { return header.largest_changestamp(); } -bool ResourceMetadataStorage::PutEntry(const std::string& id, - const ResourceEntry& entry) { +bool ResourceMetadataStorage::PutEntry(const ResourceEntry& entry) { base::ThreadRestrictions::AssertIOAllowed(); + + const std::string& id = entry.local_id(); DCHECK(!id.empty()); std::string serialized_entry; diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.h b/chrome/browser/chromeos/drive/resource_metadata_storage.h index 167f15f..28d79c2 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage.h +++ b/chrome/browser/chromeos/drive/resource_metadata_storage.h @@ -36,7 +36,7 @@ class ResourceMetadataStorage { public: // This should be incremented when incompatibility change is made to DB // format. - static const int kDBVersion = 8; + static const int kDBVersion = 9; // Object to iterate over entries stored in this storage. class Iterator { @@ -126,7 +126,7 @@ class ResourceMetadataStorage { int64 GetLargestChangestamp(); // Puts the entry to this storage. - bool PutEntry(const std::string& id, const ResourceEntry& entry); + bool PutEntry(const ResourceEntry& entry); // Gets an entry stored in this storage. bool GetEntry(const std::string& id, ResourceEntry* out_entry); diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc b/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc index 5a7a709..9dbd6dd 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc @@ -76,14 +76,14 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { const std::string name2 = "ABCD"; const std::string name3 = "EFGH"; - ResourceEntry entry1; - // key1 not found. ResourceEntry result; EXPECT_FALSE(storage_->GetEntry(key1, &result)); // Put entry1. - EXPECT_TRUE(storage_->PutEntry(key1, entry1)); + ResourceEntry entry1; + entry1.set_local_id(key1); + EXPECT_TRUE(storage_->PutEntry(entry1)); // key1 found. EXPECT_TRUE(storage_->GetEntry(key1, &result)); @@ -93,9 +93,10 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { // Put entry2 as a child of entry1. ResourceEntry entry2; + entry2.set_local_id(key2); entry2.set_parent_local_id(key1); entry2.set_base_name(name2); - EXPECT_TRUE(storage_->PutEntry(key2, entry2)); + EXPECT_TRUE(storage_->PutEntry(entry2)); // key2 found. EXPECT_TRUE(storage_->GetEntry(key2, &result)); @@ -103,9 +104,10 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { // Put entry3 as a child of entry2. ResourceEntry entry3; + entry3.set_local_id(key3); entry3.set_parent_local_id(key2); entry3.set_base_name(name3); - EXPECT_TRUE(storage_->PutEntry(key3, entry3)); + EXPECT_TRUE(storage_->PutEntry(entry3)); // key3 found. EXPECT_TRUE(storage_->GetEntry(key3, &result)); @@ -113,7 +115,7 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { // Change entry3's parent to entry1. entry3.set_parent_local_id(key1); - EXPECT_TRUE(storage_->PutEntry(key3, entry3)); + EXPECT_TRUE(storage_->PutEntry(entry3)); // entry3 is a child of entry1 now. EXPECT_TRUE(storage_->GetChild(key2, name3).empty()); @@ -137,8 +139,11 @@ TEST_F(ResourceMetadataStorageTest, Iterator) { keys.push_back("entry3"); keys.push_back("entry4"); - for (size_t i = 0; i < keys.size(); ++i) - EXPECT_TRUE(storage_->PutEntry(keys[i], ResourceEntry())); + for (size_t i = 0; i < keys.size(); ++i) { + ResourceEntry entry; + entry.set_local_id(keys[i]); + EXPECT_TRUE(storage_->PutEntry(entry)); + } // Insert some cache entries. std::map<std::string, FileCacheEntry> cache_entries; @@ -221,8 +226,11 @@ TEST_F(ResourceMetadataStorageTest, CacheEntryIterator) { EXPECT_TRUE(storage_->PutCacheEntry(it->first, it->second)); // Insert some dummy entries. - EXPECT_TRUE(storage_->PutEntry("entry1", ResourceEntry())); - EXPECT_TRUE(storage_->PutEntry("entry2", ResourceEntry())); + ResourceEntry entry; + entry.set_local_id("entry1"); + EXPECT_TRUE(storage_->PutEntry(entry)); + entry.set_local_id("entry2"); + EXPECT_TRUE(storage_->PutEntry(entry)); // Iterate and check the result. scoped_ptr<ResourceMetadataStorage::CacheEntryIterator> it = @@ -259,16 +267,20 @@ TEST_F(ResourceMetadataStorageTest, GetChildren) { children_name_id[4].push_back(std::make_pair("iapetus", "saturn_vii")); // Put parents. - for (size_t i = 0; i < arraysize(parents_id); ++i) - EXPECT_TRUE(storage_->PutEntry(parents_id[i], ResourceEntry())); + for (size_t i = 0; i < arraysize(parents_id); ++i) { + ResourceEntry entry; + entry.set_local_id(parents_id[i]); + EXPECT_TRUE(storage_->PutEntry(entry)); + } // Put children. for (size_t i = 0; i < children_name_id.size(); ++i) { for (size_t j = 0; j < children_name_id[i].size(); ++j) { ResourceEntry entry; + entry.set_local_id(children_name_id[i][j].second); entry.set_parent_local_id(parents_id[i]); entry.set_base_name(children_name_id[i][j].first); - EXPECT_TRUE(storage_->PutEntry(children_name_id[i][j].second, entry)); + EXPECT_TRUE(storage_->PutEntry(entry)); } } @@ -297,13 +309,15 @@ TEST_F(ResourceMetadataStorageTest, OpenExistingDB) { const std::string child_id1 = "qwerty"; ResourceEntry entry1; + entry1.set_local_id(parent_id1); ResourceEntry entry2; + entry2.set_local_id(child_id1); entry2.set_parent_local_id(parent_id1); entry2.set_base_name(child_name1); // Put some data. - EXPECT_TRUE(storage_->PutEntry(parent_id1, entry1)); - EXPECT_TRUE(storage_->PutEntry(child_id1, entry2)); + EXPECT_TRUE(storage_->PutEntry(entry1)); + EXPECT_TRUE(storage_->PutEntry(entry2)); // Close DB and reopen. storage_.reset(new ResourceMetadataStorage( @@ -328,7 +342,8 @@ TEST_F(ResourceMetadataStorageTest, IncompatibleDB_Old) { // Put some data. EXPECT_TRUE(storage_->SetLargestChangestamp(kLargestChangestamp)); ResourceEntry entry; - EXPECT_TRUE(storage_->PutEntry(key1, ResourceEntry())); + entry.set_local_id(key1); + EXPECT_TRUE(storage_->PutEntry(entry)); EXPECT_TRUE(storage_->GetEntry(key1, &entry)); FileCacheEntry cache_entry; EXPECT_TRUE(storage_->PutCacheEntry(key1, FileCacheEntry())); @@ -353,7 +368,8 @@ TEST_F(ResourceMetadataStorageTest, IncompatibleDB_Unknown) { // Put some data. EXPECT_TRUE(storage_->SetLargestChangestamp(kLargestChangestamp)); ResourceEntry entry; - EXPECT_TRUE(storage_->PutEntry(key1, ResourceEntry())); + entry.set_local_id(key1); + EXPECT_TRUE(storage_->PutEntry(entry)); EXPECT_TRUE(storage_->GetEntry(key1, &entry)); FileCacheEntry cache_entry; EXPECT_TRUE(storage_->PutCacheEntry(key1, FileCacheEntry())); @@ -395,14 +411,16 @@ TEST_F(ResourceMetadataStorageTest, CheckValidity) { // Put entry with key1. ResourceEntry entry; + entry.set_local_id(key1); entry.set_base_name(name1); - EXPECT_TRUE(storage_->PutEntry(key1, entry)); + EXPECT_TRUE(storage_->PutEntry(entry)); EXPECT_TRUE(CheckValidity()); // Put entry with key2 under key1. + entry.set_local_id(key2); entry.set_parent_local_id(key1); entry.set_base_name(name2); - EXPECT_TRUE(storage_->PutEntry(key2, entry)); + EXPECT_TRUE(storage_->PutEntry(entry)); EXPECT_TRUE(CheckValidity()); RemoveChild(key1, name2); @@ -417,9 +435,10 @@ TEST_F(ResourceMetadataStorageTest, CheckValidity) { EXPECT_FALSE(CheckValidity()); // key3 is not stored in the storage. // Put entry with key3 under key2. + entry.set_local_id(key3); entry.set_parent_local_id(key2); entry.set_base_name(name3); - EXPECT_TRUE(storage_->PutEntry(key3, entry)); + EXPECT_TRUE(storage_->PutEntry(entry)); EXPECT_TRUE(CheckValidity()); // Parent-child relationship with wrong name. diff --git a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc index a33f9f3..93ab5c8 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc @@ -394,7 +394,7 @@ TEST_F(ResourceMetadataTest, RefreshEntry) { ResourceEntry file_entry(entry); file_entry.set_title("file100"); EXPECT_EQ(FILE_ERROR_OK, - resource_metadata_->RefreshEntry(file_id, file_entry)); + resource_metadata_->RefreshEntry(file_entry)); EXPECT_EQ("drive/root/dir1/dir3/file100", resource_metadata_->GetFilePath(file_id).AsUTF8Unsafe()); @@ -410,7 +410,7 @@ TEST_F(ResourceMetadataTest, RefreshEntry) { file_entry = entry; file_entry.mutable_file_specific_info()->set_md5(updated_md5); EXPECT_EQ(FILE_ERROR_OK, - resource_metadata_->RefreshEntry(file_id, file_entry)); + resource_metadata_->RefreshEntry(file_entry)); EXPECT_EQ("drive/root/dir1/dir3/file100", resource_metadata_->GetFilePath(file_id).AsUTF8Unsafe()); @@ -443,7 +443,7 @@ TEST_F(ResourceMetadataTest, RefreshEntry) { ResourceEntry dir_entry(entry); dir_entry.set_title("dir100"); dir_entry.set_parent_local_id("id:dir3"); - EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->RefreshEntry(dir_id, dir_entry)); + EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->RefreshEntry(dir_entry)); EXPECT_EQ("drive/root/dir1/dir3/dir100", resource_metadata_->GetFilePath(dir_id).AsUTF8Unsafe()); @@ -468,15 +468,16 @@ TEST_F(ResourceMetadataTest, RefreshEntry) { // Make sure that directory cannot move under a file. dir_entry.set_parent_local_id(file_id); EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, - resource_metadata_->RefreshEntry(dir_id, dir_entry)); + resource_metadata_->RefreshEntry(dir_entry)); // Cannot refresh root. dir_entry.Clear(); dir_entry.set_resource_id(util::kDriveGrandRootSpecialResourceId); + dir_entry.set_local_id(util::kDriveGrandRootSpecialResourceId); dir_entry.set_title("new-root-name"); dir_entry.set_parent_local_id("id:dir1"); - EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, resource_metadata_->RefreshEntry( - util::kDriveGrandRootSpecialResourceId, dir_entry)); + EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, + resource_metadata_->RefreshEntry(dir_entry)); } TEST_F(ResourceMetadataTest, GetSubDirectoriesRecursively) { |