Chromium Code Reviews| Index: components/drive/chromeos/change_list_processor.cc |
| diff --git a/components/drive/chromeos/change_list_processor.cc b/components/drive/chromeos/change_list_processor.cc |
| index 3eb96bb1c81a47f9d7de103166f40b752d7b951f..2b9a6d32543afd136e96c831b91523f2eb466baf 100644 |
| --- a/components/drive/chromeos/change_list_processor.cc |
| +++ b/components/drive/chromeos/change_list_processor.cc |
| @@ -81,8 +81,7 @@ ChangeList::ChangeList(const google_apis::ChangeList& change_list) |
| size_t entries_index = 0; |
| for (size_t i = 0; i < items.size(); ++i) { |
| if (ConvertChangeResourceToResourceEntry( |
| - *items[i], |
| - &entries_[entries_index], |
| + *items[i], &entries_[entries_index], |
| &parent_resource_ids_[entries_index])) { |
| ++entries_index; |
| } |
| @@ -308,6 +307,8 @@ FileError ChangeListProcessor::ApplyEntryMap( |
| for (size_t i = 0; i < entries.size(); ++i) { |
| // Skip root entry in the change list. We don't expect servers to send |
| // root entry, but we should better be defensive (see crbug.com/297259). |
| + // TODO(yamaguchi): Apply this defensive logic to root directories of |
| + // every Team Drive as well. |
| ResourceEntryMap::iterator it = entries[i]; |
| if (it->first != root.resource_id()) { |
| FileError error = ApplyEntry(it->second); |
| @@ -348,19 +349,25 @@ FileError ChangeListProcessor::ApplyEntryMap( |
| FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { |
| DCHECK(!entry.deleted()); |
| + DCHECK(!entry.resource_id().empty()); |
| DCHECK(parent_resource_id_map_.count(entry.resource_id())); |
| - const std::string& parent_resource_id = |
| - parent_resource_id_map_[entry.resource_id()]; |
| ResourceEntry new_entry(entry); |
| - FileError error = SetParentLocalIdOfEntry(resource_metadata_, &new_entry, |
| - parent_resource_id); |
| - if (error != FILE_ERROR_OK) |
| - return error; |
| + // When |entry| is a root directory of a Team Drive, the parent directory of |
| + // it is "/team_drives", which doesn't have resource ID. |
| + if (entry.parent_local_id().compare(util::kDriveTeamDrivesDirLocalId) != 0) { |
|
hashimoto
2017/04/11 07:55:14
entry.parent_local_id() != util::kDriveTeamDrivesD
yamaguchi
2017/04/11 10:11:41
Done.
|
| + const std::string& parent_resource_id = |
| + parent_resource_id_map_[entry.resource_id()]; |
| + FileError error = SetParentLocalIdOfEntry(resource_metadata_, &new_entry, |
| + parent_resource_id); |
| + if (error != FILE_ERROR_OK) |
| + return error; |
| + } |
| // Lookup the entry. |
| std::string local_id; |
| - error = resource_metadata_->GetIdByResourceId(entry.resource_id(), &local_id); |
| + FileError error = |
| + resource_metadata_->GetIdByResourceId(entry.resource_id(), &local_id); |
| ResourceEntry existing_entry; |
| if (error == FILE_ERROR_OK) |