| 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/chromeos/gdata/gdata_wapi_parser.h" | 5 #include "chrome/browser/chromeos/gdata/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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 FeedEntry::RegisterJSONConverter( | 827 FeedEntry::RegisterJSONConverter( |
| 828 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); | 828 reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); |
| 829 // TODO(zelidrag): Once we figure out where these will be used, we should | 829 // TODO(zelidrag): Once we figure out where these will be used, we should |
| 830 // check for valid start_index_ and items_per_page_ values. | 830 // check for valid start_index_ and items_per_page_ values. |
| 831 converter->RegisterCustomField<int>( | 831 converter->RegisterCustomField<int>( |
| 832 kStartIndexField, &DocumentFeed::start_index_, &base::StringToInt); | 832 kStartIndexField, &DocumentFeed::start_index_, &base::StringToInt); |
| 833 converter->RegisterCustomField<int>( | 833 converter->RegisterCustomField<int>( |
| 834 kItemsPerPageField, &DocumentFeed::items_per_page_, &base::StringToInt); | 834 kItemsPerPageField, &DocumentFeed::items_per_page_, &base::StringToInt); |
| 835 converter->RegisterStringField(kTitleTField, &DocumentFeed::title_); | 835 converter->RegisterStringField(kTitleTField, &DocumentFeed::title_); |
| 836 converter->RegisterRepeatedMessage(kEntryField, &DocumentFeed::entries_); | 836 converter->RegisterRepeatedMessage(kEntryField, &DocumentFeed::entries_); |
| 837 converter->RegisterCustomField<int>( | 837 converter->RegisterCustomField<int64>( |
| 838 kLargestChangestampField, &DocumentFeed::largest_changestamp_, | 838 kLargestChangestampField, &DocumentFeed::largest_changestamp_, |
| 839 &base::StringToInt); | 839 &base::StringToInt64); |
| 840 } | 840 } |
| 841 | 841 |
| 842 bool DocumentFeed::Parse(const base::Value& value) { | 842 bool DocumentFeed::Parse(const base::Value& value) { |
| 843 base::JSONValueConverter<DocumentFeed> converter; | 843 base::JSONValueConverter<DocumentFeed> converter; |
| 844 if (!converter.Convert(value, this)) { | 844 if (!converter.Convert(value, this)) { |
| 845 DVLOG(1) << "Invalid document feed!"; | 845 DVLOG(1) << "Invalid document feed!"; |
| 846 return false; | 846 return false; |
| 847 } | 847 } |
| 848 | 848 |
| 849 ScopedVector<DocumentEntry>::iterator iter = entries_.begin(); | 849 ScopedVector<DocumentEntry>::iterator iter = entries_.begin(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 void AccountMetadataFeed::RegisterJSONConverter( | 987 void AccountMetadataFeed::RegisterJSONConverter( |
| 988 base::JSONValueConverter<AccountMetadataFeed>* converter) { | 988 base::JSONValueConverter<AccountMetadataFeed>* converter) { |
| 989 converter->RegisterCustomField<int64>( | 989 converter->RegisterCustomField<int64>( |
| 990 kQuotaBytesTotalField, | 990 kQuotaBytesTotalField, |
| 991 &AccountMetadataFeed::quota_bytes_total_, | 991 &AccountMetadataFeed::quota_bytes_total_, |
| 992 &base::StringToInt64); | 992 &base::StringToInt64); |
| 993 converter->RegisterCustomField<int64>( | 993 converter->RegisterCustomField<int64>( |
| 994 kQuotaBytesUsedField, | 994 kQuotaBytesUsedField, |
| 995 &AccountMetadataFeed::quota_bytes_used_, | 995 &AccountMetadataFeed::quota_bytes_used_, |
| 996 &base::StringToInt64); | 996 &base::StringToInt64); |
| 997 converter->RegisterCustomField<int>( | 997 converter->RegisterCustomField<int64>( |
| 998 kLargestChangestampField, | 998 kLargestChangestampField, |
| 999 &AccountMetadataFeed::largest_changestamp_, | 999 &AccountMetadataFeed::largest_changestamp_, |
| 1000 &base::StringToInt); | 1000 &base::StringToInt64); |
| 1001 converter->RegisterRepeatedMessage(kInstalledAppField, | 1001 converter->RegisterRepeatedMessage(kInstalledAppField, |
| 1002 &AccountMetadataFeed::installed_apps_); | 1002 &AccountMetadataFeed::installed_apps_); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 // static | 1005 // static |
| 1006 scoped_ptr<AccountMetadataFeed> AccountMetadataFeed::CreateFrom( | 1006 scoped_ptr<AccountMetadataFeed> AccountMetadataFeed::CreateFrom( |
| 1007 const base::Value& value) { | 1007 const base::Value& value) { |
| 1008 scoped_ptr<AccountMetadataFeed> feed(new AccountMetadataFeed()); | 1008 scoped_ptr<AccountMetadataFeed> feed(new AccountMetadataFeed()); |
| 1009 const base::DictionaryValue* dictionary = NULL; | 1009 const base::DictionaryValue* dictionary = NULL; |
| 1010 const base::Value* entry = NULL; | 1010 const base::Value* entry = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1021 bool AccountMetadataFeed::Parse(const base::Value& value) { | 1021 bool AccountMetadataFeed::Parse(const base::Value& value) { |
| 1022 base::JSONValueConverter<AccountMetadataFeed> converter; | 1022 base::JSONValueConverter<AccountMetadataFeed> converter; |
| 1023 if (!converter.Convert(value, this)) { | 1023 if (!converter.Convert(value, this)) { |
| 1024 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; | 1024 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; |
| 1025 return false; | 1025 return false; |
| 1026 } | 1026 } |
| 1027 return true; | 1027 return true; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 } // namespace gdata | 1030 } // namespace gdata |
| OLD | NEW |