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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0a4425bcaf49fedaff515cbfd98182c4a3138b90 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/gdata/drive_api_parser.h |
| @@ -0,0 +1,208 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/string_piece.h" |
| +#include "base/time.h" |
| +#include "googleurl/src/gurl.h" |
| + |
| +namespace base { |
| +class Value; |
| +template <class StructType> |
| +class JSONValueConverter; |
| + |
| +namespace internal { |
| +template <class NestedType> |
| +class RepeatedMessageConverter; |
| +} // namespace internal |
| +} // namespace base |
| + |
| +// TODO(kochi): Rename to namespace drive. http://crbug.com/136371 |
| +namespace gdata { |
| + |
| +// About resource represents the account information about the current user. |
| +class AboutResource { |
| + public: |
| + ~AboutResource(); |
| + |
| + // Registers the mapping between JSON field names and the members in this |
| + // class. |
| + static void RegisterJSONConverter( |
| + base::JSONValueConverter<AboutResource>* converter); |
| + |
| + static scoped_ptr<AboutResource> CreateFrom(const base::Value& value); |
|
satorux1
2012/07/24 16:15:26
function comment is missing. CreateFrom() and Pars
kochi
2012/07/25 06:24:04
Done.
|
| + |
| + // Parses and initializes data members from content of |value|. |
| + // Return false if parsing fails. |
| + bool Parse(const base::Value& value) OVERRIDE; |
| + |
| + const std::string& root_folder_id() const { return root_folder_id_; } |
|
satorux1
2012/07/24 16:15:26
please document this. with the old API, the root d
kochi
2012/07/25 06:24:04
The short answer is no, thus this field exists.
I
|
| + int64 quota_bytes_total() const { return quota_bytes_total_; } |
| + int64 quota_bytes_used() const { return quota_bytes_used_; } |
| + int64 largest_change_id() const { return largest_change_id_; } |
| + |
| + private: |
| + friend class DriveAPIParserTest; |
| + FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AboutResourceParser); |
| + AboutResource(); |
| + |
| + std::string root_folder_id_; |
| + int64 quota_bytes_total_; |
| + int64 quota_bytes_used_; |
| + int64 largest_change_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AboutResource); |
| +}; |
| + |
| +class DriveAppIcon { |
|
satorux1
2012/07/24 16:15:26
class comment is missing.
kochi
2012/07/25 06:24:04
Done.
|
| + public: |
| + enum IconCategory { |
| + UNKNOWN, // Uninitialized state |
| + DOCUMENT, // Document icon for various MIME types |
| + APPLICATION, // Application icon for various MIME types |
| + SHARED_DOCUMENT, // Icon for documents that are shared from other users. |
| + }; |
| + |
| + ~DriveAppIcon(); |
| + |
| + static void RegisterJSONConverter( |
| + base::JSONValueConverter<DriveAppIcon>* converter); |
| + static scoped_ptr<DriveAppIcon> CreateFrom(const base::Value& value); |
| + |
| + bool Parse(const base::Value& value); |
| + |
| + // Category of the icon. |
| + IconCategory category() const { return category_; } |
| + |
| + // Size in pixels of one side of the icon (icons are always square). |
| + int size() const { return size_; } |
|
satorux1
2012/07/24 16:15:26
size -> side_length() ?
kochi
2012/07/25 06:24:04
I tried to use the same field name as JSON, but I
|
| + |
| + const GURL& icon_url() const { return icon_url_; } |
| + |
| + private: |
| + // Extracts the icon category from the given string. Returns false and does |
| + // not change |result| when |scheme| has an unrecognizable value. |
| + static bool GetIconCategory(const base::StringPiece& category, |
| + IconCategory* result); |
| + |
| + friend class base::internal::RepeatedMessageConverter<DriveAppIcon>; |
| + friend class AppResource; |
| + DriveAppIcon(); |
| + |
| + IconCategory category_; |
| + int size_; |
| + GURL icon_url_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DriveAppIcon); |
| +}; |
| + |
| +class AppResource { |
|
satorux1
2012/07/24 16:15:26
class comment
kochi
2012/07/25 06:24:05
Done.
|
| + public: |
| + ~AppResource(); |
| + |
| + static void RegisterJSONConverter( |
| + base::JSONValueConverter<AppResource>* converter); |
| + static scoped_ptr<AppResource> CreateFrom(const base::Value& value); |
| + |
| + bool Parse(const base::Value& value); |
| + |
| + const std::string& id() const { return id_; } |
| + const std::string& name() const { return name_; } |
| + const std::string& object_type() const { return object_type_; } |
| + bool supports_create() const { return supports_create_; } |
| + bool supports_import() const { return supports_import_; } |
| + bool installed() const { return installed_; } |
| + bool authorized() const { return authorized_; } |
| + const GURL& product_url() const { return product_url_; } |
|
satorux1
2012/07/24 16:15:26
Please document these fields.
kochi
2012/07/25 06:24:05
Done.
|
| + |
| + // List of primary mime types supported by this WebApp. Primary status should |
| + // trigger this WebApp becoming the default handler of file instances that |
| + // have these mime types. |
| + const ScopedVector<std::string>& primary_mimetypes() const { |
| + return primary_mimetypes_; |
| + } |
| + |
| + // List of secondary mime types supported by this WebApp. Secondary status |
| + // should make this WebApp show up in "Open with..." pop-up menu of the |
| + // default action menu for file with matching mime types. |
| + const ScopedVector<std::string>& secondary_mimetypes() const { |
| + return secondary_mimetypes_; |
| + } |
| + |
| + // List of primary file extensions supported by this WebApp. Primary status |
| + // should trigger this WebApp becoming the default handler of file instances |
| + // that match these extensions. |
| + const ScopedVector<std::string>& primary_file_extensions() const { |
| + return primary_file_extensions_; |
| + } |
| + |
| + // List of secondary file extensions supported by this WebApp. Secondary |
| + // status should make this WebApp show up in "Open with..." pop-up menu of the |
| + // default action menu for file with matching extensions. |
| + const ScopedVector<std::string>& secondary_file_extensions() const { |
| + return secondary_file_extensions_; |
| + } |
| + |
| + const ScopedVector<DriveAppIcon>& icons() const { |
| + return icons_; |
| + } |
| + |
| + private: |
| + friend class base::internal::RepeatedMessageConverter<AppResource>; |
| + friend class AppList; |
| + AppResource(); |
| + |
| + std::string id_; |
| + std::string name_; |
| + std::string object_type_; |
| + bool supports_create_; |
| + bool supports_import_; |
| + bool installed_; |
| + bool authorized_; |
| + GURL product_url_; |
| + ScopedVector<std::string> primary_mimetypes_; |
| + ScopedVector<std::string> secondary_mimetypes_; |
| + ScopedVector<std::string> primary_file_extensions_; |
| + ScopedVector<std::string> secondary_file_extensions_; |
| + ScopedVector<DriveAppIcon> icons_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppResource); |
| +}; |
| + |
| +class AppList { |
|
satorux1
2012/07/24 16:15:26
class comment.
kochi
2012/07/25 06:24:05
Done.
|
| + public: |
| + ~AppList(); |
| + |
| + static void RegisterJSONConverter( |
| + base::JSONValueConverter<AppList>* converter); |
| + static scoped_ptr<AppList> CreateFrom(const base::Value& value); |
| + |
| + bool Parse(const base::Value& value); |
| + |
| + const std::string& etag() const { return etag_; } |
| + const ScopedVector<AppResource>& items() const { return items_; } |
| + |
| + private: |
| + friend class DriveAPIParserTest; |
| + FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AppListParser); |
| + AppList(); |
| + |
| + std::string etag_; |
| + ScopedVector<AppResource> items_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppList); |
| +}; |
| + |
| +} // namespace gdata |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ |