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

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

Issue 2577273002: Clean up IconLoader. (Closed)
Patch Set: lifetime fixed Created 4 years 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 12
13 /*static*/
sky 2016/12/16 23:27:27 style for these is // static
Avi (use Gerrit) 2016/12/17 02:28:53 Done.
14 IconLoader* IconLoader::Create(const base::FilePath& file_path,
15 IconSize size,
16 IconLoadedCallback callback) {
17 return new IconLoader(file_path, size, callback);
18 }
19
13 IconLoader::IconLoader(const base::FilePath& file_path, 20 IconLoader::IconLoader(const base::FilePath& file_path,
14 IconSize size, 21 IconSize size,
15 Delegate* delegate) 22 IconLoadedCallback callback)
16 : file_path_(file_path), 23 : file_path_(file_path), icon_size_(size), callback_(callback) {}
17 icon_size_(size),
18 delegate_(delegate) {}
19 24
20 IconLoader::~IconLoader() { 25 IconLoader::~IconLoader() {
21 } 26 }
22 27
23 void IconLoader::Start() { 28 void IconLoader::Start() {
sky 2016/12/16 23:27:27 move above constructor (to match declaration order
Avi (use Gerrit) 2016/12/17 02:28:53 Done.
24 target_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 29 target_task_runner_ = base::ThreadTaskRunnerHandle::Get();
25 30
26 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, 31 BrowserThread::PostTaskAndReply(
27 base::Bind(&IconLoader::ReadGroup, this), 32 BrowserThread::FILE, FROM_HERE,
28 base::Bind(&IconLoader::OnReadGroup, this)); 33 base::Bind(&IconLoader::ReadGroup, base::Unretained(this)),
34 base::Bind(&IconLoader::OnReadGroup, base::Unretained(this)));
29 } 35 }
30 36
31 void IconLoader::ReadGroup() { 37 void IconLoader::ReadGroup() {
32 group_ = GroupForFilepath(file_path_); 38 group_ = GroupForFilepath(file_path_);
33 } 39 }
34 40
35 void IconLoader::OnReadGroup() { 41 void IconLoader::OnReadGroup() {
36 BrowserThread::PostTask(ReadIconThreadID(), FROM_HERE, 42 BrowserThread::PostTask(
37 base::Bind(&IconLoader::ReadIcon, this)); 43 ReadIconThreadID(), FROM_HERE,
44 base::Bind(&IconLoader::ReadIcon, base::Unretained(this)));
38 } 45 }
39
40 void IconLoader::NotifyDelegate() {
41 delegate_->OnImageLoaded(this, std::move(image_), group_);
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698