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

Side by Side Diff: chrome/browser/icon_loader.cc

Issue 2953633002: Move the IconLoader to use the task scheduler. (Closed)
Patch Set: rev 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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::PostTaskWithTraitsAndReply(
gab 2017/06/22 19:49:41 This is fine so long as IconLoader::Start() is onl
Avi (use Gerrit) 2017/06/22 20:31:45 Acknowledged.
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))); 30 base::BindOnce(&IconLoader::OnReadGroup, base::Unretained(this)));
27 } 31 }
28 32
29 IconLoader::IconLoader(const base::FilePath& file_path, 33 IconLoader::IconLoader(const base::FilePath& file_path,
30 IconSize size, 34 IconSize size,
31 IconLoadedCallback callback) 35 IconLoadedCallback callback)
32 : file_path_(file_path), icon_size_(size), callback_(callback) {} 36 : file_path_(file_path), icon_size_(size), callback_(callback) {}
33 37
34 IconLoader::~IconLoader() {} 38 IconLoader::~IconLoader() {}
35 39
36 void IconLoader::ReadGroup() { 40 void IconLoader::ReadGroup() {
37 group_ = GroupForFilepath(file_path_); 41 group_ = GroupForFilepath(file_path_);
38 } 42 }
39 43
40 void IconLoader::OnReadGroup() { 44 void IconLoader::OnReadGroup() {
41 BrowserThread::PostTask( 45 ReadIconTaskRunner()->PostTask(
gab 2017/06/22 19:49:41 This is also fine because the execution model seem
Avi (use Gerrit) 2017/06/22 20:31:45 On the Linux platforms, the group determination ne
42 ReadIconThreadID(), FROM_HERE, 46 FROM_HERE, base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this)));
43 base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this)));
44 } 47 }
OLDNEW
« 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