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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 834 |
835 // static | 835 // static |
836 scoped_ptr<ResourceList> ResourceList::ExtractAndParse( | 836 scoped_ptr<ResourceList> ResourceList::ExtractAndParse( |
837 const base::Value& value) { | 837 const base::Value& value) { |
838 const base::DictionaryValue* as_dict = NULL; | 838 const base::DictionaryValue* as_dict = NULL; |
839 const base::DictionaryValue* feed_dict = NULL; | 839 const base::DictionaryValue* feed_dict = NULL; |
840 if (value.GetAsDictionary(&as_dict) && | 840 if (value.GetAsDictionary(&as_dict) && |
841 as_dict->GetDictionary(kFeedField, &feed_dict)) { | 841 as_dict->GetDictionary(kFeedField, &feed_dict)) { |
842 return ResourceList::CreateFrom(*feed_dict); | 842 return ResourceList::CreateFrom(*feed_dict); |
843 } | 843 } |
844 return scoped_ptr<ResourceList>(NULL); | 844 return scoped_ptr<ResourceList>(); |
845 } | 845 } |
846 | 846 |
847 // static | 847 // static |
848 scoped_ptr<ResourceList> ResourceList::CreateFrom(const base::Value& value) { | 848 scoped_ptr<ResourceList> ResourceList::CreateFrom(const base::Value& value) { |
849 scoped_ptr<ResourceList> feed(new ResourceList()); | 849 scoped_ptr<ResourceList> feed(new ResourceList()); |
850 if (!feed->Parse(value)) { | 850 if (!feed->Parse(value)) { |
851 DVLOG(1) << "Invalid resource list!"; | 851 DVLOG(1) << "Invalid resource list!"; |
852 return scoped_ptr<ResourceList>(NULL); | 852 return scoped_ptr<ResourceList>(); |
853 } | 853 } |
854 | 854 |
855 return feed.Pass(); | 855 return feed.Pass(); |
856 } | 856 } |
857 | 857 |
858 // static | 858 // static |
859 scoped_ptr<ResourceList> ResourceList::CreateFromChangeList( | 859 scoped_ptr<ResourceList> ResourceList::CreateFromChangeList( |
860 const ChangeList& changelist) { | 860 const ChangeList& changelist) { |
861 scoped_ptr<ResourceList> feed(new ResourceList()); | 861 scoped_ptr<ResourceList> feed(new ResourceList()); |
862 int64 largest_changestamp = 0; | 862 int64 largest_changestamp = 0; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 // static | 1032 // static |
1033 scoped_ptr<AccountMetadata> AccountMetadata::CreateFrom( | 1033 scoped_ptr<AccountMetadata> AccountMetadata::CreateFrom( |
1034 const base::Value& value) { | 1034 const base::Value& value) { |
1035 scoped_ptr<AccountMetadata> metadata(new AccountMetadata()); | 1035 scoped_ptr<AccountMetadata> metadata(new AccountMetadata()); |
1036 const base::DictionaryValue* dictionary = NULL; | 1036 const base::DictionaryValue* dictionary = NULL; |
1037 const base::Value* entry = NULL; | 1037 const base::Value* entry = NULL; |
1038 if (!value.GetAsDictionary(&dictionary) || | 1038 if (!value.GetAsDictionary(&dictionary) || |
1039 !dictionary->Get(kEntryField, &entry) || | 1039 !dictionary->Get(kEntryField, &entry) || |
1040 !metadata->Parse(*entry)) { | 1040 !metadata->Parse(*entry)) { |
1041 LOG(ERROR) << "Unable to create: Invalid account metadata feed!"; | 1041 LOG(ERROR) << "Unable to create: Invalid account metadata feed!"; |
1042 return scoped_ptr<AccountMetadata>(NULL); | 1042 return scoped_ptr<AccountMetadata>(); |
1043 } | 1043 } |
1044 | 1044 |
1045 return metadata.Pass(); | 1045 return metadata.Pass(); |
1046 } | 1046 } |
1047 | 1047 |
1048 bool AccountMetadata::Parse(const base::Value& value) { | 1048 bool AccountMetadata::Parse(const base::Value& value) { |
1049 base::JSONValueConverter<AccountMetadata> converter; | 1049 base::JSONValueConverter<AccountMetadata> converter; |
1050 if (!converter.Convert(value, this)) { | 1050 if (!converter.Convert(value, this)) { |
1051 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; | 1051 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; |
1052 return false; | 1052 return false; |
1053 } | 1053 } |
1054 return true; | 1054 return true; |
1055 } | 1055 } |
1056 | 1056 |
1057 } // namespace google_apis | 1057 } // namespace google_apis |
OLD | NEW |