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

Unified Diff: google_apis/drive/drive_api_parser.h

Issue 2748053005: Parse TeamDrive resource inside ChangeList. (Closed)
Patch Set: rebase Created 3 years, 9 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: google_apis/drive/drive_api_parser.h
diff --git a/google_apis/drive/drive_api_parser.h b/google_apis/drive/drive_api_parser.h
index da66d2123130a4b61c85cec1dc02698131918bd5..2aa3c4200c6a51d07c2be716b1c89e29d6e5f8a7 100644
--- a/google_apis/drive/drive_api_parser.h
+++ b/google_apis/drive/drive_api_parser.h
@@ -750,6 +750,11 @@ class FileList {
// https://developers.google.com/drive/v2/reference/changes
class ChangeResource {
public:
+ enum ChangeType {
+ UNKNOWN, // Uninitialized state.
+ FILE,
+ TEAM_DRIVE,
+ };
ChangeResource();
~ChangeResource();
@@ -765,16 +770,29 @@ class ChangeResource {
// number.
int64_t change_id() const { return change_id_; }
+ // Returns whether this is a change of a file or a team drive.
+ ChangeType type() const { return type_; }
+
// Returns a string file ID for corresponding file of the change.
+ // Filled only when type == FILE.
hashimoto 2017/03/22 06:40:30 What does "filled" here mean? Please use a more sp
yamaguchi 2017/03/22 07:30:36 It means uninitialized. Also added DCHECK.
const std::string& file_id() const { return file_id_; }
// Returns true if this file is deleted in the change.
bool is_deleted() const { return deleted_; }
// Returns FileResource of the file which the change refers to.
+ // Filled only when type == FILE.
hashimoto 2017/03/22 06:40:30 "Filled" here is ambiguous. If type != FILE, it's
yamaguchi 2017/03/22 07:30:36 It'll be empty (owns nothing). Added DCHECK.
const FileResource* file() const { return file_.get(); }
FileResource* mutable_file() { return file_.get(); }
+ // Returns TeamDriveResource which the change refers to.
+ // Filled only when type == TEAM_DRIVE.
hashimoto 2017/03/22 06:40:30 ditto.
yamaguchi 2017/03/22 07:30:36 Done.
+ const TeamDriveResource* team_drive() const { return team_drive_.get(); }
+ TeamDriveResource* mutable_team_drive() { return team_drive_.get(); }
+
+ // Returns the ID of the Team Drive. Filled only when type == TEAM_DRIVE.
hashimoto 2017/03/22 06:40:30 ditto.
yamaguchi 2017/03/22 07:30:36 Done.
+ const std::string& team_drive_id() const { return team_drive_id_; }
+
// Returns the time of this modification.
const base::Time& modification_date() const { return modification_date_; }
@@ -798,11 +816,19 @@ class ChangeResource {
// Return false if parsing fails.
bool Parse(const base::Value& value);
+ // Extracts the change type from the given string. Returns false and does
+ // not change |result| when |type_name| has an unrecognizable value.
+ static bool GetType(const base::StringPiece& type_name,
+ ChangeResource::ChangeType* result);
+
int64_t change_id_;
+ ChangeType type_;
std::string file_id_;
bool deleted_;
std::unique_ptr<FileResource> file_;
base::Time modification_date_;
+ std::string team_drive_id_;
+ std::unique_ptr<TeamDriveResource> team_drive_;
DISALLOW_COPY_AND_ASSIGN(ChangeResource);
};

Powered by Google App Engine
This is Rietveld 408576698