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

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_provider_impl.cc

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Comment Updates Created 3 years, 9 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/ntp_snippets/remote/remote_suggestions_provider_impl.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 } 1177 }
1178 return &content_it->second; 1178 return &content_it->second;
1179 } 1179 }
1180 1180
1181 void RemoteSuggestionsProviderImpl::RestoreCategoriesFromPrefs() { 1181 void RemoteSuggestionsProviderImpl::RestoreCategoriesFromPrefs() {
1182 // This must only be called at startup, before there are any categories. 1182 // This must only be called at startup, before there are any categories.
1183 DCHECK(category_contents_.empty()); 1183 DCHECK(category_contents_.empty());
1184 1184
1185 const base::ListValue* list = 1185 const base::ListValue* list =
1186 pref_service_->GetList(prefs::kRemoteSuggestionCategories); 1186 pref_service_->GetList(prefs::kRemoteSuggestionCategories);
1187 for (const std::unique_ptr<base::Value>& entry : *list) { 1187 for (const base::Value& entry : *list) {
1188 const base::DictionaryValue* dict = nullptr; 1188 const base::DictionaryValue* dict = nullptr;
1189 if (!entry->GetAsDictionary(&dict)) { 1189 if (!entry.GetAsDictionary(&dict)) {
1190 DLOG(WARNING) << "Invalid category pref value: " << *entry; 1190 DLOG(WARNING) << "Invalid category pref value: " << entry;
1191 continue; 1191 continue;
1192 } 1192 }
1193 int id = 0; 1193 int id = 0;
1194 if (!dict->GetInteger(kCategoryContentId, &id)) { 1194 if (!dict->GetInteger(kCategoryContentId, &id)) {
1195 DLOG(WARNING) << "Invalid category pref value, missing '" 1195 DLOG(WARNING) << "Invalid category pref value, missing '"
1196 << kCategoryContentId << "': " << *entry; 1196 << kCategoryContentId << "': " << entry;
1197 continue; 1197 continue;
1198 } 1198 }
1199 base::string16 title; 1199 base::string16 title;
1200 if (!dict->GetString(kCategoryContentTitle, &title)) { 1200 if (!dict->GetString(kCategoryContentTitle, &title)) {
1201 DLOG(WARNING) << "Invalid category pref value, missing '" 1201 DLOG(WARNING) << "Invalid category pref value, missing '"
1202 << kCategoryContentTitle << "': " << *entry; 1202 << kCategoryContentTitle << "': " << entry;
1203 continue; 1203 continue;
1204 } 1204 }
1205 bool included_in_last_server_response = false; 1205 bool included_in_last_server_response = false;
1206 if (!dict->GetBoolean(kCategoryContentProvidedByServer, 1206 if (!dict->GetBoolean(kCategoryContentProvidedByServer,
1207 &included_in_last_server_response)) { 1207 &included_in_last_server_response)) {
1208 DLOG(WARNING) << "Invalid category pref value, missing '" 1208 DLOG(WARNING) << "Invalid category pref value, missing '"
1209 << kCategoryContentProvidedByServer << "': " << *entry; 1209 << kCategoryContentProvidedByServer << "': " << entry;
1210 continue; 1210 continue;
1211 } 1211 }
1212 bool allow_fetching_more_results = false; 1212 bool allow_fetching_more_results = false;
1213 // This wasn't always around, so it's okay if it's missing. 1213 // This wasn't always around, so it's okay if it's missing.
1214 dict->GetBoolean(kCategoryContentAllowFetchingMore, 1214 dict->GetBoolean(kCategoryContentAllowFetchingMore,
1215 &allow_fetching_more_results); 1215 &allow_fetching_more_results);
1216 1216
1217 Category category = Category::FromIDValue(id); 1217 Category category = Category::FromIDValue(id);
1218 // The ranker may not persist the order of remote categories. 1218 // The ranker may not persist the order of remote categories.
1219 category_ranker_->AppendCategoryIfNecessary(category); 1219 category_ranker_->AppendCategoryIfNecessary(category);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent( 1269 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent(
1270 CategoryContent&&) = default; 1270 CategoryContent&&) = default;
1271 1271
1272 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default; 1272 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default;
1273 1273
1274 RemoteSuggestionsProviderImpl::CategoryContent& 1274 RemoteSuggestionsProviderImpl::CategoryContent&
1275 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) = 1275 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) =
1276 default; 1276 default;
1277 1277
1278 } // namespace ntp_snippets 1278 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698