Chromium Code Reviews| 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 e1b08f8d2986be26ccbb552d73f3de4b23da9dce..fb8f17853960df6ed5bc11c95d3cd2e862bf0ed3 100644 |
| --- a/chrome/browser/chromeos/gdata/drive_api_parser.h |
| +++ b/chrome/browser/chromeos/gdata/drive_api_parser.h |
| @@ -257,7 +257,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: |
| @@ -267,6 +301,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. |
| @@ -289,6 +325,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_; } |
| @@ -303,6 +342,7 @@ class FileResource { |
| private: |
| friend class base::internal::RepeatedMessageConverter<FileResource>; |
| + friend class ChangeResource; |
| friend class FileList; |
| FileResource(); |
| @@ -315,6 +355,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_; |
| @@ -333,6 +374,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. |
| @@ -366,6 +409,92 @@ class FileList { |
| DISALLOW_COPY_AND_ASSIGN(FileList); |
| }; |
| +class ChangeResource { |
|
satorux1
2012/08/02 16:41:51
class comment is missing. what is a change resourc
kochi
2012/08/02 17:16:47
Done.
|
| + 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); |
| +}; |
| + |
| +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_ |