1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/icon_loader.h"
9 #include "base/functional/bind.h"
10 #include "base/task/single_thread_task_runner.h"
11 #include "base/task/thread_pool.h"
12 #include "build/build_config.h"
13 #include "content/public/browser/browser_thread.h"
15 using content::BrowserThread;
18 void IconLoader::LoadIcon(const base::FilePath& file_path,
21 IconLoadedCallback callback) {
22 (new IconLoader(file_path, size, scale, std::move(callback)))->Start();
25 IconLoader::IconLoader(const base::FilePath& file_path,
28 IconLoadedCallback callback)
29 : file_path_(file_path),
30 #if !BUILDFLAG(IS_ANDROID)
34 callback_(std::move(callback)) {
37 IconLoader::~IconLoader() = default;
39 #if !BUILDFLAG(IS_CHROMEOS)
40 void IconLoader::Start() {
41 target_task_runner_ = base::SingleThreadTaskRunner::GetCurrentDefault();
43 base::ThreadPool::PostTask(
45 base::BindOnce(&IconLoader::ReadGroup, base::Unretained(this)));
48 #if !BUILDFLAG(IS_WIN)
49 void IconLoader::ReadGroup() {
50 group_ = GroupForFilepath(file_path_);
52 GetReadIconTaskRunner()->PostTask(
53 FROM_HERE, base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this)));
55 #endif // !BUILDFLAG(IS_WIN)
56 #endif // !BUILDFLAG(IS_CHROMEOS)