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

Side by Side Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/content_suggestions_service.h" 5 #include "components/ntp_snippets/content_suggestions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 599 }
600 } 600 }
601 601
602 void ContentSuggestionsService::RestoreDismissedCategoriesFromPrefs() { 602 void ContentSuggestionsService::RestoreDismissedCategoriesFromPrefs() {
603 // This must only be called at startup. 603 // This must only be called at startup.
604 DCHECK(dismissed_providers_by_category_.empty()); 604 DCHECK(dismissed_providers_by_category_.empty());
605 DCHECK(providers_by_category_.empty()); 605 DCHECK(providers_by_category_.empty());
606 606
607 const base::ListValue* list = 607 const base::ListValue* list =
608 pref_service_->GetList(prefs::kDismissedCategories); 608 pref_service_->GetList(prefs::kDismissedCategories);
609 for (const base::Value& entry : *list) { 609 for (const std::unique_ptr<base::Value>& entry : *list) {
610 int id = 0; 610 int id = 0;
611 if (!entry.GetAsInteger(&id)) { 611 if (!entry->GetAsInteger(&id)) {
612 DLOG(WARNING) << "Invalid category pref value: " << entry; 612 DLOG(WARNING) << "Invalid category pref value: " << *entry;
613 continue; 613 continue;
614 } 614 }
615 615
616 // When the provider is registered, it will be stored in this map. 616 // When the provider is registered, it will be stored in this map.
617 dismissed_providers_by_category_[Category::FromIDValue(id)] = nullptr; 617 dismissed_providers_by_category_[Category::FromIDValue(id)] = nullptr;
618 } 618 }
619 } 619 }
620 620
621 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 621 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
622 base::ListValue list; 622 base::ListValue list;
623 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 623 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
624 list.AppendInteger(category_provider_pair.first.id()); 624 list.AppendInteger(category_provider_pair.first.id());
625 } 625 }
626 626
627 pref_service_->Set(prefs::kDismissedCategories, list); 627 pref_service_->Set(prefs::kDismissedCategories, list);
628 } 628 }
629 629
630 } // namespace ntp_snippets 630 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/category_rankers/click_based_category_ranker.cc ('k') | components/ntp_snippets/pref_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698