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

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2212313002: Call FetchImageCallback asynchronously when no thumbnail exists (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarksprovider
Patch Set: Marc's comments 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 1b9ecb839cb7d4cedb90f40dc88d6be2ce605fd9..43ee91ef2542ea02ef3d1af0723761ffe8b84ee5 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -8,7 +8,9 @@
#include <iterator>
#include "base/bind.h"
+#include "base/location.h"
#include "base/strings/string_number_conversions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "ui/gfx/image/image.h"
namespace ntp_snippets {
@@ -61,14 +63,16 @@ void ContentSuggestionsService::FetchSuggestionImage(
const ImageFetchedCallback& callback) {
if (!id_category_map_.count(suggestion_id)) {
LOG(WARNING) << "Requested image for unknown suggestion " << suggestion_id;
- callback.Run(suggestion_id, gfx::Image());
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image()));
return;
}
Category category = id_category_map_.at(suggestion_id);
if (!providers_by_category_.count(category)) {
LOG(WARNING) << "Requested image for suggestion " << suggestion_id
<< " for unavailable category " << category;
- callback.Run(suggestion_id, gfx::Image());
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image()));
return;
}
providers_by_category_[category]->FetchSuggestionImage(suggestion_id,

Powered by Google App Engine
This is Rietveld 408576698