OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Converts value of link.rel into LinkType. Outputs to |type| and returns | 94 // Converts value of link.rel into LinkType. Outputs to |type| and returns |
95 // true when |rel| has a valid value. Otherwise does nothing and returns | 95 // true when |rel| has a valid value. Otherwise does nothing and returns |
96 // false. | 96 // false. |
97 static bool GetLinkType(const base::StringPiece& rel, LinkType* type); | 97 static bool GetLinkType(const base::StringPiece& rel, LinkType* type); |
98 | 98 |
99 // Converts value of link.rel to application ID, if there is one embedded in | 99 // Converts value of link.rel to application ID, if there is one embedded in |
100 // the link.rel field. Outputs to |app_id| and returns true when |rel| has a | 100 // the link.rel field. Outputs to |app_id| and returns true when |rel| has a |
101 // valid value. Otherwise does nothing and returns false. | 101 // valid value. Otherwise does nothing and returns false. |
102 static bool GetAppID(const base::StringPiece& rel, std::string* app_id); | 102 static bool GetAppID(const base::StringPiece& rel, std::string* app_id); |
103 | 103 |
104 | |
105 LinkType type_; | 104 LinkType type_; |
106 GURL href_; | 105 GURL href_; |
107 string16 title_; | 106 string16 title_; |
108 std::string app_id_; | 107 std::string app_id_; |
109 std::string mime_type_; | 108 std::string mime_type_; |
110 | 109 |
111 DISALLOW_COPY_AND_ASSIGN(Link); | 110 DISALLOW_COPY_AND_ASSIGN(Link); |
112 }; | 111 }; |
113 | 112 |
114 // Feed links define links (URLs) to special list of entries (i.e. list of | 113 // Feed links define links (URLs) to special list of entries (i.e. list of |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 424 |
426 // Document feed file content MD5 (exists only for kinds FILE and PDF). | 425 // Document feed file content MD5 (exists only for kinds FILE and PDF). |
427 const std::string& file_md5() const { return file_md5_; } | 426 const std::string& file_md5() const { return file_md5_; } |
428 | 427 |
429 // Document feed file size (exists only for kinds FILE and PDF). | 428 // Document feed file size (exists only for kinds FILE and PDF). |
430 int64 file_size() const { return file_size_; } | 429 int64 file_size() const { return file_size_; } |
431 | 430 |
432 // True if the file or directory is deleted (applicable to change feeds only). | 431 // True if the file or directory is deleted (applicable to change feeds only). |
433 bool deleted() const { return deleted_ || removed_; } | 432 bool deleted() const { return deleted_ || removed_; } |
434 | 433 |
435 // Text version of document entry kind. Returns an empty string for | 434 // Text version of document entry kind. Returns an empty string for |
436 // unknown entry kind. | 435 // unknown entry kind. |
437 std::string GetEntryKindText() const; | 436 std::string GetEntryKindText() const; |
438 | 437 |
439 // Returns preferred file extension for hosted documents. If entry is not | 438 // Returns preferred file extension for hosted documents. If entry is not |
440 // a hosted document, this call returns an empty string. | 439 // a hosted document, this call returns an empty string. |
441 std::string GetHostedDocumentExtension() const; | 440 std::string GetHostedDocumentExtension() const; |
442 | 441 |
443 // True if document entry is remotely hosted. | 442 // True if document entry is remotely hosted. |
444 bool is_hosted_document() const { return (kind_ & 0x002000) == 0x002000; } | 443 bool is_hosted_document() const { return (kind_ & 0x002000) == 0x002000; } |
445 // True if document entry hosted by Google Documents. | 444 // True if document entry hosted by Google Documents. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 const ScopedVector<DocumentEntry>& entries() const { return entries_; } | 526 const ScopedVector<DocumentEntry>& entries() const { return entries_; } |
528 | 527 |
529 // Start index of the document entry list. | 528 // Start index of the document entry list. |
530 int start_index() const { return start_index_; } | 529 int start_index() const { return start_index_; } |
531 | 530 |
532 // Number of items per feed of the document entry list. | 531 // Number of items per feed of the document entry list. |
533 int items_per_page() const { return items_per_page_; } | 532 int items_per_page() const { return items_per_page_; } |
534 | 533 |
535 // The largest changestamp. Next time the documents should be fetched | 534 // The largest changestamp. Next time the documents should be fetched |
536 // from this changestamp. | 535 // from this changestamp. |
537 int largest_changestamp() const { return largest_changestamp_; } | 536 int64 largest_changestamp() const { return largest_changestamp_; } |
538 | 537 |
539 // Document entry list title. | 538 // Document entry list title. |
540 const std::string& title() { return title_; } | 539 const std::string& title() { return title_; } |
541 | 540 |
542 private: | 541 private: |
543 DocumentFeed(); | 542 DocumentFeed(); |
544 | 543 |
545 // Parses and initializes data members from content of |value|. | 544 // Parses and initializes data members from content of |value|. |
546 // Return false if parsing fails. | 545 // Return false if parsing fails. |
547 bool Parse(const base::Value& value); | 546 bool Parse(const base::Value& value); |
548 | 547 |
549 ScopedVector<DocumentEntry> entries_; | 548 ScopedVector<DocumentEntry> entries_; |
550 int start_index_; | 549 int start_index_; |
551 int items_per_page_; | 550 int items_per_page_; |
552 std::string title_; | 551 std::string title_; |
553 int largest_changestamp_; | 552 int64 largest_changestamp_; |
554 | 553 |
555 DISALLOW_COPY_AND_ASSIGN(DocumentFeed); | 554 DISALLOW_COPY_AND_ASSIGN(DocumentFeed); |
556 }; | 555 }; |
557 | 556 |
558 // Metadata representing installed Google Drive application. | 557 // Metadata representing installed Google Drive application. |
559 class InstalledApp { | 558 class InstalledApp { |
560 public: | 559 public: |
561 typedef std::vector<std::pair<int, GURL> > IconList; | 560 typedef std::vector<std::pair<int, GURL> > IconList; |
562 | 561 |
563 InstalledApp(); | 562 InstalledApp(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 static scoped_ptr<AccountMetadataFeed> CreateFrom(const base::Value& value); | 654 static scoped_ptr<AccountMetadataFeed> CreateFrom(const base::Value& value); |
656 | 655 |
657 int64 quota_bytes_total() const { | 656 int64 quota_bytes_total() const { |
658 return quota_bytes_total_; | 657 return quota_bytes_total_; |
659 } | 658 } |
660 | 659 |
661 int64 quota_bytes_used() const { | 660 int64 quota_bytes_used() const { |
662 return quota_bytes_used_; | 661 return quota_bytes_used_; |
663 } | 662 } |
664 | 663 |
665 int largest_changestamp() const { | 664 int64 largest_changestamp() const { |
666 return largest_changestamp_; | 665 return largest_changestamp_; |
667 } | 666 } |
668 | 667 |
669 const ScopedVector<InstalledApp>& installed_apps() const { | 668 const ScopedVector<InstalledApp>& installed_apps() const { |
670 return installed_apps_; | 669 return installed_apps_; |
671 } | 670 } |
672 | 671 |
673 // Registers the mapping between JSON field names and the members in | 672 // Registers the mapping between JSON field names and the members in |
674 // this class. | 673 // this class. |
675 static void RegisterJSONConverter( | 674 static void RegisterJSONConverter( |
676 base::JSONValueConverter<AccountMetadataFeed>* converter); | 675 base::JSONValueConverter<AccountMetadataFeed>* converter); |
677 | 676 |
678 private: | 677 private: |
679 AccountMetadataFeed(); | 678 AccountMetadataFeed(); |
680 | 679 |
681 // Parses and initializes data members from content of |value|. | 680 // Parses and initializes data members from content of |value|. |
682 // Return false if parsing fails. | 681 // Return false if parsing fails. |
683 bool Parse(const base::Value& value); | 682 bool Parse(const base::Value& value); |
684 | 683 |
685 int64 quota_bytes_total_; | 684 int64 quota_bytes_total_; |
686 int64 quota_bytes_used_; | 685 int64 quota_bytes_used_; |
687 int largest_changestamp_; | 686 int64 largest_changestamp_; |
688 ScopedVector<InstalledApp> installed_apps_; | 687 ScopedVector<InstalledApp> installed_apps_; |
689 | 688 |
690 DISALLOW_COPY_AND_ASSIGN(AccountMetadataFeed); | 689 DISALLOW_COPY_AND_ASSIGN(AccountMetadataFeed); |
691 }; | 690 }; |
692 | 691 |
693 | 692 |
694 } // namespace gdata | 693 } // namespace gdata |
695 | 694 |
696 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ | 695 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_PARSER_H_ |
OLD | NEW |