Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_parser.cc

Issue 11428046: Add changestamp field to google_apis::DocumentEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude from android build Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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::ParseChangestamp(const base::Value* value,
611 int64* result) {
612 DCHECK(result);
613 if (!value) {
614 *result = 0;
615 return true;
616 }
617
618 std::string string_value;
619 if (value->GetAsString(&string_value) &&
620 base::StringToInt64(string_value, result))
621 return true;
622
623 return false;
624 }
625
608 // static 626 // static
609 void DocumentEntry::RegisterJSONConverter( 627 void DocumentEntry::RegisterJSONConverter(
610 base::JSONValueConverter<DocumentEntry>* converter) { 628 base::JSONValueConverter<DocumentEntry>* converter) {
611 // Inherit the parent registrations. 629 // Inherit the parent registrations.
612 FeedEntry::RegisterJSONConverter( 630 FeedEntry::RegisterJSONConverter(
613 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); 631 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter));
614 converter->RegisterStringField( 632 converter->RegisterStringField(
615 kResourceIdField, &DocumentEntry::resource_id_); 633 kResourceIdField, &DocumentEntry::resource_id_);
616 converter->RegisterStringField(kIDField, &DocumentEntry::id_); 634 converter->RegisterStringField(kIDField, &DocumentEntry::id_);
617 converter->RegisterStringField(kTitleTField, &DocumentEntry::title_); 635 converter->RegisterStringField(kTitleTField, &DocumentEntry::title_);
(...skipping 15 matching lines...) Expand all
633 converter->RegisterCustomField<int64>( 651 converter->RegisterCustomField<int64>(
634 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64); 652 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64);
635 converter->RegisterStringField( 653 converter->RegisterStringField(
636 kSuggestedFileNameField, &DocumentEntry::suggested_filename_); 654 kSuggestedFileNameField, &DocumentEntry::suggested_filename_);
637 // Deleted are treated as 'trashed' items on web client side. Removed files 655 // 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. 656 // are gone for good. We treat both cases as 'deleted' for this client.
639 converter->RegisterCustomValueField<bool>( 657 converter->RegisterCustomValueField<bool>(
640 kDeletedField, &DocumentEntry::deleted_, &DocumentEntry::HasFieldPresent); 658 kDeletedField, &DocumentEntry::deleted_, &DocumentEntry::HasFieldPresent);
641 converter->RegisterCustomValueField<bool>( 659 converter->RegisterCustomValueField<bool>(
642 kRemovedField, &DocumentEntry::removed_, &DocumentEntry::HasFieldPresent); 660 kRemovedField, &DocumentEntry::removed_, &DocumentEntry::HasFieldPresent);
661 converter->RegisterCustomValueField<int64>(
662 kChangestampField, &DocumentEntry::changestamp_,
663 &DocumentEntry::ParseChangestamp);
643 } 664 }
644 665
645 std::string DocumentEntry::GetHostedDocumentExtension() const { 666 std::string DocumentEntry::GetHostedDocumentExtension() const {
646 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) { 667 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) {
647 if (kEntryKindMap[i].kind == kind_) { 668 if (kEntryKindMap[i].kind == kind_) {
648 if (kEntryKindMap[i].extension) 669 if (kEntryKindMap[i].extension)
649 return std::string(kEntryKindMap[i].extension); 670 return std::string(kEntryKindMap[i].extension);
650 else 671 else
651 return std::string(); 672 return std::string();
652 } 673 }
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 bool AccountMetadataFeed::Parse(const base::Value& value) { 1203 bool AccountMetadataFeed::Parse(const base::Value& value) {
1183 base::JSONValueConverter<AccountMetadataFeed> converter; 1204 base::JSONValueConverter<AccountMetadataFeed> converter;
1184 if (!converter.Convert(value, this)) { 1205 if (!converter.Convert(value, this)) {
1185 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; 1206 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!";
1186 return false; 1207 return false;
1187 } 1208 }
1188 return true; 1209 return true;
1189 } 1210 }
1190 1211
1191 } // namespace google_apis 1212 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_parser.h ('k') | chrome/browser/google_apis/gdata_wapi_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698