summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/google_apis/gdata_wapi_parser.cc24
-rw-r--r--chrome/browser/google_apis/gdata_wapi_parser.h11
2 files changed, 18 insertions, 17 deletions
diff --git a/chrome/browser/google_apis/gdata_wapi_parser.cc b/chrome/browser/google_apis/gdata_wapi_parser.cc
index 30d47f8..d3fac42 100644
--- a/chrome/browser/google_apis/gdata_wapi_parser.cc
+++ b/chrome/browser/google_apis/gdata_wapi_parser.cc
@@ -475,16 +475,18 @@ FeedEntry::~FeedEntry() {
}
// static
+template<typename FeedEntryDescendant>
void FeedEntry::RegisterJSONConverter(
- base::JSONValueConverter<FeedEntry>* converter) {
+ base::JSONValueConverter<FeedEntryDescendant>* converter) {
converter->RegisterStringField(kETagField, &FeedEntry::etag_);
- converter->RegisterRepeatedMessage(kAuthorField, &FeedEntry::authors_);
- converter->RegisterRepeatedMessage(kLinkField, &FeedEntry::links_);
- converter->RegisterRepeatedMessage(kCategoryField, &FeedEntry::categories_);
- converter->RegisterCustomField<base::Time>(
- kUpdatedField,
- &FeedEntry::updated_time_,
- &util::GetTimeFromString);
+ converter->template RegisterRepeatedMessage<Author>(
+ kAuthorField, &FeedEntry::authors_);
+ converter->template RegisterRepeatedMessage<Link>(
+ kLinkField, &FeedEntry::links_);
+ converter->template RegisterRepeatedMessage<Category>(
+ kCategoryField, &FeedEntry::categories_);
+ converter->template RegisterCustomField<base::Time>(
+ kUpdatedField, &FeedEntry::updated_time_, &util::GetTimeFromString);
}
////////////////////////////////////////////////////////////////////////////////
@@ -527,8 +529,7 @@ bool ResourceEntry::ParseChangestamp(const base::Value* value,
void ResourceEntry::RegisterJSONConverter(
base::JSONValueConverter<ResourceEntry>* converter) {
// Inherit the parent registrations.
- FeedEntry::RegisterJSONConverter(
- reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter));
+ FeedEntry::RegisterJSONConverter(converter);
converter->RegisterStringField(
kResourceIdField, &ResourceEntry::resource_id_);
converter->RegisterStringField(kIDField, &ResourceEntry::id_);
@@ -793,8 +794,7 @@ ResourceList::~ResourceList() {
void ResourceList::RegisterJSONConverter(
base::JSONValueConverter<ResourceList>* converter) {
// inheritance
- FeedEntry::RegisterJSONConverter(
- reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter));
+ FeedEntry::RegisterJSONConverter(converter);
// TODO(zelidrag): Once we figure out where these will be used, we should
// check for valid start_index_ and items_per_page_ values.
converter->RegisterCustomField<int>(
diff --git a/chrome/browser/google_apis/gdata_wapi_parser.h b/chrome/browser/google_apis/gdata_wapi_parser.h
index 7a59b5f..bd430df 100644
--- a/chrome/browser/google_apis/gdata_wapi_parser.h
+++ b/chrome/browser/google_apis/gdata_wapi_parser.h
@@ -336,11 +336,6 @@ class FeedEntry {
// List of entry categories.
const ScopedVector<Category>& categories() const { return categories_; }
- // Registers the mapping between JSON field names and the members in
- // this class.
- static void RegisterJSONConverter(
- base::JSONValueConverter<FeedEntry>* converter);
-
void set_etag(const std::string& etag) { etag_ = etag; }
void set_authors(ScopedVector<Author>* authors) {
authors_.swap(*authors);
@@ -356,6 +351,12 @@ class FeedEntry {
}
protected:
+ // Registers the mapping between JSON field names and the members in
+ // this class.
+ template<typename FeedEntryDescendant>
+ static void RegisterJSONConverter(
+ base::JSONValueConverter<FeedEntryDescendant>* converter);
+
std::string etag_;
ScopedVector<Author> authors_;
ScopedVector<Link> links_;