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 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 const char kResourceIdNode[] = "resourceId"; | 61 const char kResourceIdNode[] = "resourceId"; |
62 const char kSizeNode[] = "size"; | 62 const char kSizeNode[] = "size"; |
63 const char kSuggestedFilenameNode[] = "suggestedFilename"; | 63 const char kSuggestedFilenameNode[] = "suggestedFilename"; |
64 const char kTitleNode[] = "title"; | 64 const char kTitleNode[] = "title"; |
65 const char kUpdatedNode[] = "updated"; | 65 const char kUpdatedNode[] = "updated"; |
66 const char kWritersCanInviteNode[] = "writersCanInvite"; | 66 const char kWritersCanInviteNode[] = "writersCanInvite"; |
67 | 67 |
68 // Field names. | 68 // Field names. |
69 const char kAuthorField[] = "author"; | 69 const char kAuthorField[] = "author"; |
70 const char kCategoryField[] = "category"; | 70 const char kCategoryField[] = "category"; |
71 const char kChangestampField[] = "docs$changestamp.value"; | |
71 const char kContentField[] = "content"; | 72 const char kContentField[] = "content"; |
72 const char kDeletedField[] = "gd$deleted"; | 73 const char kDeletedField[] = "gd$deleted"; |
73 const char kETagField[] = "gd$etag"; | 74 const char kETagField[] = "gd$etag"; |
74 const char kEmailField[] = "email.$t"; | 75 const char kEmailField[] = "email.$t"; |
75 const char kEntryField[] = "entry"; | 76 const char kEntryField[] = "entry"; |
76 const char kFeedField[] = "feed"; | 77 const char kFeedField[] = "feed"; |
77 const char kFeedLinkField[] = "gd$feedLink"; | 78 const char kFeedLinkField[] = "gd$feedLink"; |
78 const char kFileNameField[] = "docs$filename.$t"; | 79 const char kFileNameField[] = "docs$filename.$t"; |
79 const char kHrefField[] = "href"; | 80 const char kHrefField[] = "href"; |
80 const char kIDField[] = "id.$t"; | 81 const char kIDField[] = "id.$t"; |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 &google_apis::util::GetTimeFromString); | 587 &google_apis::util::GetTimeFromString); |
587 } | 588 } |
588 | 589 |
589 //////////////////////////////////////////////////////////////////////////////// | 590 //////////////////////////////////////////////////////////////////////////////// |
590 // DocumentEntry implementation | 591 // DocumentEntry implementation |
591 | 592 |
592 DocumentEntry::DocumentEntry() | 593 DocumentEntry::DocumentEntry() |
593 : kind_(ENTRY_KIND_UNKNOWN), | 594 : kind_(ENTRY_KIND_UNKNOWN), |
594 file_size_(0), | 595 file_size_(0), |
595 deleted_(false), | 596 deleted_(false), |
596 removed_(false) { | 597 removed_(false), |
598 changestamp_(0) { | |
597 } | 599 } |
598 | 600 |
599 DocumentEntry::~DocumentEntry() { | 601 DocumentEntry::~DocumentEntry() { |
600 } | 602 } |
601 | 603 |
602 bool DocumentEntry::HasFieldPresent(const base::Value* value, | 604 bool DocumentEntry::HasFieldPresent(const base::Value* value, |
603 bool* result) { | 605 bool* result) { |
604 *result = (value != NULL); | 606 *result = (value != NULL); |
605 return true; | 607 return true; |
606 } | 608 } |
607 | 609 |
610 bool DocumentEntry::OptionalChangestamp(const base::StringPiece& value, | |
611 int64* result) { | |
satorux1
2012/12/03 05:59:57
DCHECK(result);
tzik
2012/12/03 06:16:34
Done.
| |
612 if (!base::StringToInt64(value, result)) | |
613 *result = 0; | |
614 return true; | |
615 } | |
616 | |
608 // static | 617 // static |
609 void DocumentEntry::RegisterJSONConverter( | 618 void DocumentEntry::RegisterJSONConverter( |
610 base::JSONValueConverter<DocumentEntry>* converter) { | 619 base::JSONValueConverter<DocumentEntry>* converter) { |
611 // Inherit the parent registrations. | 620 // Inherit the parent registrations. |
612 FeedEntry::RegisterJSONConverter( | 621 FeedEntry::RegisterJSONConverter( |
613 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); | 622 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); |
614 converter->RegisterStringField( | 623 converter->RegisterStringField( |
615 kResourceIdField, &DocumentEntry::resource_id_); | 624 kResourceIdField, &DocumentEntry::resource_id_); |
616 converter->RegisterStringField(kIDField, &DocumentEntry::id_); | 625 converter->RegisterStringField(kIDField, &DocumentEntry::id_); |
617 converter->RegisterStringField(kTitleTField, &DocumentEntry::title_); | 626 converter->RegisterStringField(kTitleTField, &DocumentEntry::title_); |
(...skipping 15 matching lines...) Expand all Loading... | |
633 converter->RegisterCustomField<int64>( | 642 converter->RegisterCustomField<int64>( |
634 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64); | 643 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64); |
635 converter->RegisterStringField( | 644 converter->RegisterStringField( |
636 kSuggestedFileNameField, &DocumentEntry::suggested_filename_); | 645 kSuggestedFileNameField, &DocumentEntry::suggested_filename_); |
637 // Deleted are treated as 'trashed' items on web client side. Removed files | 646 // Deleted are treated as 'trashed' items on web client side. Removed files |
638 // are gone for good. We treat both cases as 'deleted' for this client. | 647 // are gone for good. We treat both cases as 'deleted' for this client. |
639 converter->RegisterCustomValueField<bool>( | 648 converter->RegisterCustomValueField<bool>( |
640 kDeletedField, &DocumentEntry::deleted_, &DocumentEntry::HasFieldPresent); | 649 kDeletedField, &DocumentEntry::deleted_, &DocumentEntry::HasFieldPresent); |
641 converter->RegisterCustomValueField<bool>( | 650 converter->RegisterCustomValueField<bool>( |
642 kRemovedField, &DocumentEntry::removed_, &DocumentEntry::HasFieldPresent); | 651 kRemovedField, &DocumentEntry::removed_, &DocumentEntry::HasFieldPresent); |
652 converter->RegisterCustomField<int64>( | |
653 kChangestampField, &DocumentEntry::changestamp_, | |
654 &DocumentEntry::OptionalChangestamp); | |
643 } | 655 } |
644 | 656 |
645 std::string DocumentEntry::GetHostedDocumentExtension() const { | 657 std::string DocumentEntry::GetHostedDocumentExtension() const { |
646 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) { | 658 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) { |
647 if (kEntryKindMap[i].kind == kind_) { | 659 if (kEntryKindMap[i].kind == kind_) { |
648 if (kEntryKindMap[i].extension) | 660 if (kEntryKindMap[i].extension) |
649 return std::string(kEntryKindMap[i].extension); | 661 return std::string(kEntryKindMap[i].extension); |
650 else | 662 else |
651 return std::string(); | 663 return std::string(); |
652 } | 664 } |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1182 bool AccountMetadataFeed::Parse(const base::Value& value) { | 1194 bool AccountMetadataFeed::Parse(const base::Value& value) { |
1183 base::JSONValueConverter<AccountMetadataFeed> converter; | 1195 base::JSONValueConverter<AccountMetadataFeed> converter; |
1184 if (!converter.Convert(value, this)) { | 1196 if (!converter.Convert(value, this)) { |
1185 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; | 1197 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; |
1186 return false; | 1198 return false; |
1187 } | 1199 } |
1188 return true; | 1200 return true; |
1189 } | 1201 } |
1190 | 1202 |
1191 } // namespace google_apis | 1203 } // namespace google_apis |
OLD | NEW |