Chromium Code Reviews| Index: components/drive/chromeos/resource_metadata.cc |
| diff --git a/components/drive/chromeos/resource_metadata.cc b/components/drive/chromeos/resource_metadata.cc |
| index d482dc252e86f04293ab1b2c5011a29dbd91d3f1..fead78d6259607a5b589417baf0fa70581e53ece 100644 |
| --- a/components/drive/chromeos/resource_metadata.cc |
| +++ b/components/drive/chromeos/resource_metadata.cc |
| @@ -122,6 +122,63 @@ ResourceMetadata::~ResourceMetadata() { |
| DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| } |
| +FileError ResourceMetadata::AddTeamDrive(const std::string& id, |
|
hashimoto
2017/04/06 10:23:36
Do we need these new methods?
I think the same thi
yamaguchi
2017/04/07 03:57:43
Changed to have them processed as normal Entries.
|
| + const std::string& name) { |
| + ResourceEntry entry; |
| + FileError error = storage_->GetEntry(id, &entry); |
| + if (error != FILE_ERROR_NOT_FOUND) { |
| + return FILE_ERROR_EXISTS; |
| + } |
| + ResourceEntry team_drive; |
| + team_drive.mutable_file_info()->set_is_directory(true); |
| + team_drive.set_local_id(id); |
| + team_drive.set_parent_local_id(util::kDriveTeamDrivesDirLocalId); |
| + team_drive.set_title(name.empty() ? id : name); |
| + team_drive.set_resource_id(id); |
| + return PutEntryUnderDirectory(team_drive); |
| +} |
| + |
| +FileError ResourceMetadata::RefreshTeamDrive(const std::string& id, |
| + const std::string& name) { |
| + DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| + |
| + if (!EnoughDiskSpaceIsAvailableForDBOperation(storage_->directory_path())) |
| + return FILE_ERROR_NO_LOCAL_SPACE; |
| + |
| + ResourceEntry old_entry; |
| + FileError error = storage_->GetEntry(id, &old_entry); |
| + if (error != FILE_ERROR_OK) |
| + return error; |
| + |
| + if (IsImmutableEntry(id) || |
| + old_entry.file_info().is_directory() != // Reject incompatible input. |
| + true) |
| + return FILE_ERROR_INVALID_OPERATION; |
| + |
| + if (!id.empty()) { |
| + // Multiple entries cannot share the same resource ID. |
| + std::string local_id; |
| + FileError error = GetIdByResourceId(id, &local_id); |
| + switch (error) { |
| + case FILE_ERROR_OK: |
| + if (local_id != id) |
| + return FILE_ERROR_INVALID_OPERATION; |
| + break; |
| + |
| + case FILE_ERROR_NOT_FOUND: |
| + break; |
| + |
| + default: |
| + return error; |
| + } |
| + } |
| + |
| + ResourceEntry updated_entry(old_entry); |
| + updated_entry.set_title(name); |
| + // Remove from the old parent and add it to the new parent with the new data. |
| + return PutEntryUnderDirectory(updated_entry); |
| +} |
| + |
| FileError ResourceMetadata::SetUpDefaultEntries() { |
| DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |