Chromium Code Reviews| 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; |
| } |