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..a43f51c6656d63aeae3dba4d9b3d4139ca9f1df7 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,99 @@ 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_; } |
+ |
+ // 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_ |