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

Unified Diff: content/child/notifications/notification_image_loader.cc

Issue 1644083002: Fetch notification action icons and pass them through in resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ActionIconBlink
Patch Set: Rebase. Created 4 years, 10 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: content/child/notifications/notification_image_loader.cc
diff --git a/content/child/notifications/notification_image_loader.cc b/content/child/notifications/notification_image_loader.cc
index 4eed91fa3be624782ce07d5131c69d7fcb84a2f2..df621ffd28da21778eac58da9bc10612cdc13520 100644
--- a/content/child/notifications/notification_image_loader.cc
+++ b/content/child/notifications/notification_image_loader.cc
@@ -4,9 +4,11 @@
#include "content/child/notifications/notification_image_loader.h"
+#include "base/bind.h"
+#include "base/location.h"
#include "base/logging.h"
+#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
-#include "content/child/child_thread_impl.h"
#include "content/child/image_decoder.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -26,7 +28,6 @@ NotificationImageLoader::NotificationImageLoader(
const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner)
: callback_(callback),
worker_task_runner_(worker_task_runner),
- notification_id_(0),
completed_(false) {}
NotificationImageLoader::~NotificationImageLoader() {
@@ -34,13 +35,10 @@ NotificationImageLoader::~NotificationImageLoader() {
DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
}
-void NotificationImageLoader::StartOnMainThread(int notification_id,
- const GURL& image_url) {
- DCHECK(ChildThreadImpl::current());
+void NotificationImageLoader::StartOnMainThread(const GURL& image_url) {
DCHECK(!url_loader_);
main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- notification_id_ = notification_id;
WebURL image_web_url(image_url);
WebURLRequest request(image_web_url);
@@ -84,10 +82,9 @@ void NotificationImageLoader::RunCallbackOnWorkerThread() {
SkBitmap icon = GetDecodedImage();
if (worker_task_runner_->BelongsToCurrentThread()) {
- callback_.Run(notification_id_, icon);
+ callback_.Run(icon);
} else {
- worker_task_runner_->PostTask(
- FROM_HERE, base::Bind(callback_, notification_id_, icon));
+ worker_task_runner_->PostTask(FROM_HERE, base::Bind(callback_, icon));
}
}
@@ -101,7 +98,8 @@ SkBitmap NotificationImageLoader::GetDecodedImage() const {
}
void NotificationImageLoader::DeleteOnCorrectThread() const {
- if (!ChildThreadImpl::current()) {
+ if (main_thread_task_runner_ &&
+ !main_thread_task_runner_->BelongsToCurrentThread()) {
main_thread_task_runner_->DeleteSoon(FROM_HERE, this);
return;
}

Powered by Google App Engine
This is Rietveld 408576698