blob: a4934f00ca3df3945f0716db33d63161215e256a [file] [log] [blame]
[email protected]679facce2012-07-25 16:13:121// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0f38ceae2009-05-08 19:01:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/icon_loader.h"
6
avif4d431c2017-06-22 23:30:537#include <utility>
8
[email protected]a27a2bc2011-11-15 21:25:519#include "base/bind.h"
avif4d431c2017-06-22 23:30:5310#include "base/task_scheduler/post_task.h"
11#include "base/task_scheduler/task_traits.h"
gabb15e19072016-05-11 20:45:4112#include "base/threading/thread_task_runner_handle.h"
[email protected]c38831a12011-10-28 12:44:4913#include "content/public/browser/browser_thread.h"
[email protected]0f38ceae2009-05-08 19:01:0214
[email protected]631bb742011-11-02 11:29:3915using content::BrowserThread;
16
avif0a7b5b812016-12-17 19:01:3117// static
18IconLoader* IconLoader::Create(const base::FilePath& file_path,
19 IconSize size,
20 IconLoadedCallback callback) {
21 return new IconLoader(file_path, size, callback);
[email protected]0f38ceae2009-05-08 19:01:0222}
23
24void IconLoader::Start() {
pranay.kumar4b8db4d2015-04-29 11:12:0425 target_task_runner_ = base::ThreadTaskRunnerHandle::Get();
[email protected]0f38ceae2009-05-08 19:01:0226
avif4d431c2017-06-22 23:30:5327 base::PostTaskWithTraits(
28 FROM_HERE, traits(),
29 base::BindOnce(&IconLoader::ReadGroup, base::Unretained(this)));
[email protected]bc0147b2013-04-03 20:50:5930}
31
avif0a7b5b812016-12-17 19:01:3132IconLoader::IconLoader(const base::FilePath& file_path,
33 IconSize size,
34 IconLoadedCallback callback)
35 : file_path_(file_path), icon_size_(size), callback_(callback) {}
36
37IconLoader::~IconLoader() {}
38
[email protected]bc0147b2013-04-03 20:50:5939void IconLoader::ReadGroup() {
avi381f719f2016-12-16 00:05:0240 group_ = GroupForFilepath(file_path_);
[email protected]bc0147b2013-04-03 20:50:5941
avif4d431c2017-06-22 23:30:5342 GetReadIconTaskRunner()->PostTask(
43 FROM_HERE, base::BindOnce(&IconLoader::ReadIcon, base::Unretained(this)));
[email protected]0f38ceae2009-05-08 19:01:0244}