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

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

Issue 897733002: worker: Use standard task-runners to run notification image loader callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whoops Created 5 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 c194b024c4835e26dc94d088d632315b9ee77455..a844a4357033767f7457879cd7867216e80c20fe 100644
--- a/content/child/notifications/notification_image_loader.cc
+++ b/content/child/notifications/notification_image_loader.cc
@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "content/child/child_thread_impl.h"
#include "content/child/image_decoder.h"
-#include "content/child/worker_task_runner.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLLoader.h"
@@ -27,12 +26,14 @@ NotificationImageLoader::NotificationImageLoader(
NotificationImageLoader::~NotificationImageLoader() {}
-void NotificationImageLoader::StartOnMainThread(const WebURL& image_url,
- int worker_thread_id) {
+void NotificationImageLoader::StartOnMainThread(
+ const WebURL& image_url,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner) {
DCHECK(ChildThreadImpl::current());
DCHECK(!url_loader_);
+ DCHECK(worker_task_runner);
- worker_thread_id_ = worker_thread_id;
+ worker_task_runner_ = worker_task_runner;
WebURLRequest request(image_url);
request.setRequestContext(WebURLRequest::RequestContextImage);
@@ -79,14 +80,10 @@ void NotificationImageLoader::didFail(WebURLLoader* loader,
void NotificationImageLoader::RunCallbackOnWorkerThread() {
scoped_refptr<NotificationImageLoader> loader = make_scoped_refptr(this);
- if (!worker_thread_id_) {
+ if (worker_task_runner_->BelongsToCurrentThread())
callback_.Run(loader);
- return;
- }
-
- WorkerTaskRunner::Instance()->PostTask(
- worker_thread_id_,
- base::Bind(callback_, loader));
+ else
+ worker_task_runner_->PostTask(FROM_HERE, base::Bind(callback_, loader));
}
} // namespace content
« no previous file with comments | « content/child/notifications/notification_image_loader.h ('k') | content/child/notifications/notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698