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

Unified Diff: chrome/browser/icon_loader.cc

Issue 2953633002: Move the IconLoader to use the task scheduler. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « chrome/browser/icon_loader.h ('k') | chrome/browser/icon_loader_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_loader.cc
diff --git a/chrome/browser/icon_loader.cc b/chrome/browser/icon_loader.cc
index d679bd3598331ad1bda2c5228218a4bef291b110..50cd8b68710d0f844be626cc954159bfda229027 100644
--- a/chrome/browser/icon_loader.cc
+++ b/chrome/browser/icon_loader.cc
@@ -4,7 +4,11 @@
#include "chrome/browser/icon_loader.h"
+#include <utility>
+
#include "base/bind.h"
+#include "base/task_scheduler/post_task.h"
+#include "base/task_scheduler/task_traits.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/browser/browser_thread.h"
@@ -20,8 +24,8 @@ IconLoader* IconLoader::Create(const base::FilePath& file_path,
void IconLoader::Start() {
target_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- BrowserThread::PostTaskAndReply(
- BrowserThread::FILE, FROM_HERE,
+ base::PostTaskWithTraitsAndReply(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&IconLoader::ReadGroup, base::Unretained(this)),
base::BindOnce(&IconLoader::OnReadGroup, base::Unretained(this)));
}
@@ -38,7 +42,14 @@ void IconLoader::ReadGroup() {
}
void IconLoader::OnReadGroup() {
- BrowserThread::PostTask(
- ReadIconThreadID(), FROM_HERE,
- base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this)));
+ auto read_icon =
+ base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this));
+ if (ReadIconRequiresUIThread()) {
+ content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI)
+ ->PostTask(FROM_HERE, std::move(read_icon));
gab 2017/06/22 15:38:35 content::BrowserThread::PostTask(content::BrowserT
+ } else {
+ base::PostTaskWithTraits(
gab 2017/06/22 15:38:35 If you need COM you'll need to (on OS_WIN): base:
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
sky 2017/06/22 00:43:25 optional: create a function to return the traits t
Avi (use Gerrit) 2017/06/22 01:21:17 Ben: Is that the style for the new PostTask?
gab 2017/06/22 15:38:35 TaskTraits is constexpr, you can store them in a c
+ std::move(read_icon));
+ }
}
« no previous file with comments | « chrome/browser/icon_loader.h ('k') | chrome/browser/icon_loader_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698