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