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

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2292003002: Move OnURLsDeleted from NTPSnippetsService to ContentSuggestionsService (Closed)
Patch Set: Created 4 years, 3 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 c1977e50c8767454c388edfb5c1b7d1a5de75e82..6f75814f565ff9c1e566d3d9816ddc0dc8acbeff 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -15,8 +15,14 @@
namespace ntp_snippets {
-ContentSuggestionsService::ContentSuggestionsService(State state)
- : state_(state) {}
+ContentSuggestionsService::ContentSuggestionsService(
+ State state,
+ history::HistoryService* history_service)
+ : state_(state), history_service_observer_(this) {
+ // Can be null in tests.
+ if (history_service)
+ history_service_observer_.Add(history_service);
+}
ContentSuggestionsService::~ContentSuggestionsService() {}
@@ -230,6 +236,30 @@ void ContentSuggestionsService::OnSuggestionInvalidated(
OnSuggestionInvalidated(category, suggestion_id));
}
+// history::HistoryServiceObserver implementation.
+void ContentSuggestionsService::OnURLsDeleted(
+ history::HistoryService* history_service,
+ bool all_history,
+ bool expired,
+ const history::URLRows& deleted_rows,
+ const std::set<GURL>& favicon_urls) {
+ if (expired)
Marc Treib 2016/09/02 12:57:10 Add a comment, like we had in NTPSnippetsService?
vitaliii 2016/09/02 14:13:17 Done.
+ return;
+
+ std::vector<GURL> deleted_urls;
+ for (const history::URLRow& row : deleted_rows) {
+ deleted_urls.emplace_back(row.url());
Marc Treib 2016/09/02 12:57:10 nit: push_back, since it has to make a copy anyway
vitaliii 2016/09/02 14:13:17 Acknowledged.
+ }
+ for (const auto& provider : providers_) {
+ provider->RemoveURLsFromHistory(all_history, deleted_urls);
+ }
+}
+
+void ContentSuggestionsService::HistoryServiceBeingDeleted(
+ history::HistoryService* history_service) {
+ history_service_observer_.RemoveAll();
+}
+
bool ContentSuggestionsService::RegisterCategoryIfRequired(
ContentSuggestionsProvider* provider,
Category category) {

Powered by Google App Engine
This is Rietveld 408576698