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/ntp_snippets_service.cc

Issue 2158883002: Change NTPSnippetsBridge to read from ContentSuggestionsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offlinepagesprovider
Patch Set: Created 4 years, 5 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/ntp_snippets_service.cc
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
index fc3ff800a0df056db1dfd871d2462c917971c4a1..cc791f4f403d323f1c3a2fc7a94093f92c1e15a0 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -277,10 +277,11 @@ void NTPSnippetsService::RescheduleFetching() {
void NTPSnippetsService::FetchSuggestionImage(
const std::string& suggestion_id,
const ImageFetchedCallback& callback) {
+ std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id);
database_->LoadImage(
- suggestion_id,
Marc Treib 2016/07/19 09:30:25 Wait, so this only worked because suggestion_id wa
Philipp Keck 2016/07/19 12:21:50 Yes. This method implements two different interfac
+ snippet_id,
base::Bind(&NTPSnippetsService::OnSnippetImageFetchedFromDatabase,
- base::Unretained(this), suggestion_id, callback));
+ base::Unretained(this), snippet_id, callback));
}
void NTPSnippetsService::ClearCachedSuggestionsForDebugging() {
@@ -310,11 +311,13 @@ void NTPSnippetsService::DiscardSuggestion(const std::string& suggestion_id) {
if (!ready())
return;
- auto it = std::find_if(
- snippets_.begin(), snippets_.end(),
- [&suggestion_id](const std::unique_ptr<NTPSnippet>& snippet) {
- return snippet->id() == suggestion_id;
- });
+ std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id);
+
+ auto it =
+ std::find_if(snippets_.begin(), snippets_.end(),
+ [&snippet_id](const std::unique_ptr<NTPSnippet>& snippet) {
+ return snippet->id() == snippet_id;
+ });
if (it == snippets_.end())
return;
@@ -325,8 +328,6 @@ void NTPSnippetsService::DiscardSuggestion(const std::string& suggestion_id) {
discarded_snippets_.push_back(std::move(*it));
snippets_.erase(it);
-
- NotifyNewSuggestions();
}
void NTPSnippetsService::ClearDiscardedSuggestionsForDebugging() {
@@ -619,7 +620,8 @@ void NTPSnippetsService::OnSnippetImageDecoded(
const ImageFetchedCallback& callback,
const gfx::Image& image) {
if (!image.IsEmpty()) {
- callback.Run(snippet_id, image);
+ callback.Run(MakeUniqueID(ContentSuggestionsCategory::ARTICLES, snippet_id),
+ image);
return;
}
@@ -638,7 +640,8 @@ void NTPSnippetsService::FetchSnippetImageFromNetwork(
return snippet->id() == snippet_id;
});
if (it == snippets_.end()) {
- callback.Run(snippet_id, gfx::Image());
+ callback.Run(MakeUniqueID(ContentSuggestionsCategory::ARTICLES, snippet_id),
+ gfx::Image());
return;
}

Powered by Google App Engine
This is Rietveld 408576698