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

Unified Diff: google_apis/drive/drive_api_parser.cc

Issue 2885323002: Add URL generator / json parser for getting start_page_token of changes. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « google_apis/drive/drive_api_parser.h ('k') | google_apis/drive/drive_api_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/drive/drive_api_parser.cc
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc
index 3e8975d1e4a2e7055a2897ede3b4aacd50038cca..d402687f2ee1444f7c98b1cf63ba19f0316bce20 100644
--- a/google_apis/drive/drive_api_parser.cc
+++ b/google_apis/drive/drive_api_parser.cc
@@ -211,6 +211,11 @@ const char kTeamDriveId[] = "teamDriveId";
// https://developers.google.com/drive/v2/reference/changes/list
const char kChangeListKind[] = "drive#changeList";
+// Changes StartPageToken
+// https://developers.google.com/drive/v2/reference/changes/getStartPageToken
+const char kStartPageTokenKind[] = "drive#startPageToken";
+const char kStartPageToken[] = "startPageToken";
+
// Maps category name to enum ChangeType.
struct ChangeTypeMap {
ChangeResource::ChangeType type;
@@ -783,6 +788,45 @@ bool ChangeResource::GetType(const base::StringPiece& type_name,
}
////////////////////////////////////////////////////////////////////////////////
+// StartPageToken implementation
+
+StartPageToken::StartPageToken() {}
+
+StartPageToken::~StartPageToken() {}
+
+// static
+void StartPageToken::RegisterJSONConverter(
+ base::JSONValueConverter<StartPageToken>* converter) {
+ converter->RegisterStringField(kStartPageToken,
+ &StartPageToken::start_page_token_);
+}
+
+// static
+bool StartPageToken::HasStartPageTokenKind(const base::Value& value) {
+ return IsResourceKindExpected(value, kStartPageTokenKind);
+}
+
+// static
+std::unique_ptr<StartPageToken> StartPageToken::CreateFrom(
+ const base::Value& value) {
+ std::unique_ptr<StartPageToken> resource(new StartPageToken());
+ if (!HasStartPageTokenKind(value) || !resource->Parse(value)) {
+ LOG(ERROR) << "Unable to create: Invalid StartPageToken JSON!";
+ return std::unique_ptr<StartPageToken>();
+ }
+ return resource;
+}
+
+bool StartPageToken::Parse(const base::Value& value) {
+ base::JSONValueConverter<StartPageToken> converter;
+ if (!converter.Convert(value, this)) {
+ LOG(ERROR) << "Unable to parse: Invalid StartPageToken";
+ return false;
+ }
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// ChangeList implementation
ChangeList::ChangeList() : largest_change_id_(0) {}
« no previous file with comments | « google_apis/drive/drive_api_parser.h ('k') | google_apis/drive/drive_api_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698