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

Unified Diff: chrome/browser/chromeos/gdata/drive_api_parser.h

Issue 10829139: Add parsers for Drive v2 Change/ChangeList/Parents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added class comments. Created 8 years, 5 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 | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/drive_api_parser.h
diff --git a/chrome/browser/chromeos/gdata/drive_api_parser.h b/chrome/browser/chromeos/gdata/drive_api_parser.h
index 704c3cc0b1d919b05de42b0e92e5479b95656c35..3dc16d68c141ad2a0d3c4c2391acceaf0b83148f 100644
--- a/chrome/browser/chromeos/gdata/drive_api_parser.h
+++ b/chrome/browser/chromeos/gdata/drive_api_parser.h
@@ -258,7 +258,41 @@ class AppList {
DISALLOW_COPY_AND_ASSIGN(AppList);
};
-// FileResource reporesents a file or folder metadata in Drive.
+// ParentReference represents a directory.
+// https://developers.google.com/drive/v2/reference/parents
+class ParentReference {
+ public:
+ ~ParentReference();
+
+ // Registers the mapping between JSON field names and the members in this
+ // class.
+ static void RegisterJSONConverter(
+ base::JSONValueConverter<ParentReference>* converter);
+
+ // Creates parent reference from parsed JSON.
+ static scoped_ptr<ParentReference> CreateFrom(const base::Value& value);
+
+ // Returns the file id of the reference.
+ const std::string& file_id() const { return file_id_; }
+
+ // Returns true if the reference is root directory.
+ bool is_root() const { return is_root_; }
+
+ private:
+ friend class base::internal::RepeatedMessageConverter<ParentReference>;
+ ParentReference();
+
+ // Parses and initializes data members from content of |value|.
+ // Return false if parsing fails.
+ bool Parse(const base::Value& value);
+
+ std::string file_id_;
+ bool is_root_;
+
+ DISALLOW_COPY_AND_ASSIGN(ParentReference);
+};
+
+// FileResource represents a file or folder metadata in Drive.
// https://developers.google.com/drive/v2/reference/files
class FileResource {
public:
@@ -268,6 +302,8 @@ class FileResource {
// class.
static void RegisterJSONConverter(
base::JSONValueConverter<FileResource>* converter);
+
+ // Creates file resource from parsed JSON.
static scoped_ptr<FileResource> CreateFrom(const base::Value& value);
// Returns true if this is a directory.
@@ -290,6 +326,9 @@ class FileResource {
// Returns modification time by the user.
const base::Time& modified_by_me_date() const { return modified_by_me_date_; }
+ // Returns parent references (directories) of this file.
+ const ScopedVector<ParentReference>& parents() const { return parents_; }
+
// Returns the download URL.
const GURL& download_url() const { return download_url_; }
@@ -304,6 +343,7 @@ class FileResource {
private:
friend class base::internal::RepeatedMessageConverter<FileResource>;
+ friend class ChangeResource;
friend class FileList;
FileResource();
@@ -316,6 +356,7 @@ class FileResource {
std::string mime_type_;
std::string title_;
base::Time modified_by_me_date_;
+ ScopedVector<ParentReference> parents_;
GURL download_url_;
std::string file_extension_;
std::string md5_checksum_;
@@ -334,6 +375,8 @@ class FileList {
// class.
static void RegisterJSONConverter(
base::JSONValueConverter<FileList>* converter);
+
+ // Creates file list from parsed JSON.
static scoped_ptr<FileList> CreateFrom(const base::Value& value);
// Returns the ETag of the list.
@@ -367,6 +410,96 @@ class FileList {
DISALLOW_COPY_AND_ASSIGN(FileList);
};
+// ChangeResource represents a change in a file.
+// https://developers.google.com/drive/v2/reference/changes
+class ChangeResource {
+ public:
+ ~ChangeResource();
+
+ // Registers the mapping between JSON field names and the members in this
+ // class.
+ static void RegisterJSONConverter(
+ base::JSONValueConverter<ChangeResource>* converter);
+
+ // Creates change resource from parsed JSON.
+ static scoped_ptr<ChangeResource> CreateFrom(const base::Value& value);
+
+ // Returns change ID for this change. This is a monotonically increasing
+ // number.
+ int64 change_id() const { return change_id_; }
satorux1 2012/08/02 19:39:18 please add a blank line between accessors.
+ // Returns a string file ID for corresponding file of the change.
+ 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.
+ const FileResource& file() const { return file_; }
+
+ private:
+ friend class base::internal::RepeatedMessageConverter<ChangeResource>;
+ friend class ChangeList;
+ ChangeResource();
+
+ // Parses and initializes data members from content of |value|.
+ // Return false if parsing fails.
+ bool Parse(const base::Value& value);
+
+ int64 change_id_;
+ std::string file_id_;
+ bool deleted_;
+ FileResource file_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChangeResource);
+};
+
+// ChangeList represents a set of changes in the drive.
+// https://developers.google.com/drive/v2/reference/changes/list
+class ChangeList {
+ public:
+ ~ChangeList();
+
+ // Registers the mapping between JSON field names and the members in this
+ // class.
+ static void RegisterJSONConverter(
+ base::JSONValueConverter<ChangeList>* converter);
+
+ // Creates change list from parsed JSON.
+ static scoped_ptr<ChangeList> CreateFrom(const base::Value& value);
+
+ // Returns the ETag of the list.
+ const std::string& etag() const { return etag_; }
+
+ // Returns the page token for the next page of files, if the list is large
+ // to fit in one response. If this is empty, there is no more file lists.
+ const std::string& next_page_token() const { return next_page_token_; }
+
+ // Returns a link to the next page of files. The URL includes the next page
+ // token.
+ const GURL& next_link() const { return next_link_; }
+
+ // Returns the largest change ID number.
+ int64 largest_change_id() const { return largest_change_id_; }
+
+ // Returns a set of changes in this list.
+ const ScopedVector<ChangeResource>& items() const { return items_; }
+
+ private:
+ friend class DriveAPIParserTest;
+ FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, ChangeListParser);
+ ChangeList();
+
+ // Parses and initializes data members from content of |value|.
+ // Return false if parsing fails.
+ bool Parse(const base::Value& value);
+
+ std::string etag_;
+ std::string next_page_token_;
+ GURL next_link_;
+ int64 largest_change_id_;
+ ScopedVector<ChangeResource> items_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChangeList);
+};
+
} // namespace gdata
#endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698