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

Unified Diff: components/drive/resource_entry_conversion.cc

Issue 2799603002: Process TeamDrive change in change list. (Closed)
Patch Set: Handle changes to Team Drive by the same path as files, including deletion. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/drive/resource_entry_conversion.cc
diff --git a/components/drive/resource_entry_conversion.cc b/components/drive/resource_entry_conversion.cc
index 52eda29bffc8b0f0c4a9c826d707920a90129d48..5e042cdd1d651e702ee3691e13a620f60645cc91 100644
--- a/components/drive/resource_entry_conversion.cc
+++ b/components/drive/resource_entry_conversion.cc
@@ -26,12 +26,17 @@ bool ConvertChangeResourceToResourceEntry(
ResourceEntry converted;
std::string parent_resource_id;
- if (input.file() &&
- !ConvertFileResourceToResourceEntry(*input.file(), &converted,
- &parent_resource_id))
+ if (input.type() == google_apis::ChangeResource::TEAM_DRIVE) {
+ if (!ConvertTeamDriveChangeResourceToResourceEntry(input, &converted,
+ &parent_resource_id)) {
return false;
-
- converted.set_resource_id(input.file_id());
+ }
+ } else {
+ if (input.file() && !ConvertFileResourceToResourceEntry(
+ *input.file(), &converted, &parent_resource_id))
+ return false;
+ converted.set_resource_id(input.file_id());
+ }
converted.set_deleted(converted.deleted() || input.is_deleted());
converted.set_modification_date(input.modification_date().ToInternalValue());
@@ -141,4 +146,24 @@ void ConvertResourceEntryToFileInfo(const ResourceEntry& entry,
entry.file_info().creation_time());
}
+bool ConvertTeamDriveChangeResourceToResourceEntry(
hashimoto 2017/04/10 11:01:24 For FileResource, we have ConvertFileResourceToRes
yamaguchi 2017/04/11 07:08:07 Splitted ConvertTeamDriveResourceToResourceEntry,
+ const google_apis::ChangeResource& input,
+ ResourceEntry* out_entry,
+ std::string* out_parent_resource_id) {
+ DCHECK(out_entry);
+ DCHECK(out_parent_resource_id);
+ DCHECK_EQ(google_apis::ChangeResource::TEAM_DRIVE, input.type());
+ ResourceEntry converted;
+ converted.mutable_file_info()->set_is_directory(true);
+ converted.set_parent_local_id(util::kDriveTeamDrivesDirLocalId);
+ *out_parent_resource_id = util::kDriveTeamDrivesDirVirtualResourceId;
+ if (input.team_drive()) {
+ converted.set_title(input.team_drive()->name());
+ converted.set_base_name(input.team_drive()->name());
+ }
+ converted.set_resource_id(input.team_drive_id());
+ out_entry->Swap(&converted);
+ return true;
+}
+
} // namespace drive

Powered by Google App Engine
This is Rietveld 408576698