OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/task_scheduler/post_task.h" |
| 11 #include "base/task_scheduler/task_traits.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
9 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
10 | 14 |
11 using content::BrowserThread; | 15 using content::BrowserThread; |
12 | 16 |
13 // static | 17 // static |
14 IconLoader* IconLoader::Create(const base::FilePath& file_path, | 18 IconLoader* IconLoader::Create(const base::FilePath& file_path, |
15 IconSize size, | 19 IconSize size, |
16 IconLoadedCallback callback) { | 20 IconLoadedCallback callback) { |
17 return new IconLoader(file_path, size, callback); | 21 return new IconLoader(file_path, size, callback); |
18 } | 22 } |
19 | 23 |
20 void IconLoader::Start() { | 24 void IconLoader::Start() { |
21 target_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 25 target_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
22 | 26 |
23 BrowserThread::PostTaskAndReply( | 27 base::PostTaskWithTraits( |
24 BrowserThread::FILE, FROM_HERE, | 28 FROM_HERE, traits(), |
25 base::BindOnce(&IconLoader::ReadGroup, base::Unretained(this)), | 29 base::BindOnce(&IconLoader::ReadGroup, base::Unretained(this))); |
26 base::BindOnce(&IconLoader::OnReadGroup, base::Unretained(this))); | |
27 } | 30 } |
28 | 31 |
29 IconLoader::IconLoader(const base::FilePath& file_path, | 32 IconLoader::IconLoader(const base::FilePath& file_path, |
30 IconSize size, | 33 IconSize size, |
31 IconLoadedCallback callback) | 34 IconLoadedCallback callback) |
32 : file_path_(file_path), icon_size_(size), callback_(callback) {} | 35 : file_path_(file_path), icon_size_(size), callback_(callback) {} |
33 | 36 |
34 IconLoader::~IconLoader() {} | 37 IconLoader::~IconLoader() {} |
35 | 38 |
36 void IconLoader::ReadGroup() { | 39 void IconLoader::ReadGroup() { |
37 group_ = GroupForFilepath(file_path_); | 40 group_ = GroupForFilepath(file_path_); |
| 41 |
| 42 ReadIconTaskRunner()->PostTask( |
| 43 FROM_HERE, base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this))); |
38 } | 44 } |
39 | |
40 void IconLoader::OnReadGroup() { | |
41 BrowserThread::PostTask( | |
42 ReadIconThreadID(), FROM_HERE, | |
43 base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this))); | |
44 } | |
OLD | NEW |