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

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2222853004: Add per-section clearing and dismissed suggestions to snippets-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/content_suggestions_service.cc
diff --git a/components/ntp_snippets/content_suggestions_service.cc b/components/ntp_snippets/content_suggestions_service.cc
index 43ee91ef2542ea02ef3d1af0723761ffe8b84ee5..ab6839db0f05d28920730adb8c3293e946c095be 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -79,19 +79,42 @@ void ContentSuggestionsService::FetchSuggestionImage(
callback);
}
-void ContentSuggestionsService::ClearCachedSuggestionsForDebugging() {
+void ContentSuggestionsService::ClearAllCachedSuggestionsForDebugging() {
suggestions_by_category_.clear();
id_category_map_.clear();
for (auto& category_provider_pair : providers_by_category_) {
Marc Treib 2016/08/08 13:52:09 const auto&
Philipp Keck 2016/08/08 14:15:09 Done.
- category_provider_pair.second->ClearCachedSuggestionsForDebugging();
+ category_provider_pair.second->ClearCachedSuggestionsForDebugging(
+ category_provider_pair.first);
}
FOR_EACH_OBSERVER(Observer, observers_, OnNewSuggestions());
}
-void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging() {
- for (auto& category_provider_pair : providers_by_category_) {
- category_provider_pair.second->ClearDismissedSuggestionsForDebugging();
+void ContentSuggestionsService::ClearCachedSuggestionsForDebugging(
+ Category category) {
+ for (const ContentSuggestion& suggestion :
+ suggestions_by_category_[category]) {
+ id_category_map_.erase(suggestion.id());
}
+ suggestions_by_category_[category] = std::vector<ContentSuggestion>();
Marc Treib 2016/08/08 13:52:09 .clear() ?
Philipp Keck 2016/08/08 14:15:09 Done.
+ auto iterator = providers_by_category_.find(category);
+ if (iterator != providers_by_category_.end())
+ iterator->second->ClearCachedSuggestionsForDebugging(category);
+}
+
+std::vector<ContentSuggestion>
+ContentSuggestionsService::GetDismissedSuggestionsForDebugging(
+ Category category) {
+ auto iterator = providers_by_category_.find(category);
+ if (iterator == providers_by_category_.end())
+ return std::vector<ContentSuggestion>();
+ return iterator->second->GetDismissedSuggestionsForDebugging(category);
+}
+
+void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging(
+ Category category) {
+ auto iterator = providers_by_category_.find(category);
+ if (iterator != providers_by_category_.end())
+ iterator->second->ClearDismissedSuggestionsForDebugging(category);
}
void ContentSuggestionsService::DismissSuggestion(

Powered by Google App Engine
This is Rietveld 408576698