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

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

Issue 2953633002: Move the IconLoader to use the task scheduler. (Closed)
Patch Set: sky 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_auralinux.cc ('k') | chrome/browser/icon_loader_mac.mm » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 } // namespace 185 } // namespace
186 186
187 // static 187 // static
188 IconLoader::IconGroup IconLoader::GroupForFilepath( 188 IconLoader::IconGroup IconLoader::GroupForFilepath(
189 const base::FilePath& file_path) { 189 const base::FilePath& file_path) {
190 return base::ToLowerASCII(file_path.Extension()); 190 return base::ToLowerASCII(file_path.Extension());
191 } 191 }
192 192
193 // static 193 // static
194 content::BrowserThread::ID IconLoader::ReadIconThreadID() { 194 scoped_refptr<base::TaskRunner> IconLoader::GetReadIconTaskRunner() {
195 // ReadIcon touches non thread safe ResourceBundle images, so it must be on 195 // ReadIcon touches non thread safe ResourceBundle images, so it must be on
196 // the UI thread. 196 // the UI thread.
197 return content::BrowserThread::UI; 197 return content::BrowserThread::GetTaskRunnerForThread(
198 content::BrowserThread::UI);
198 } 199 }
199 200
200 void IconLoader::ReadIcon() { 201 void IconLoader::ReadIcon() {
201 static base::LazyInstance<IconMapper>::Leaky icon_mapper = 202 static base::LazyInstance<IconMapper>::Leaky icon_mapper =
202 LAZY_INSTANCE_INITIALIZER; 203 LAZY_INSTANCE_INITIALIZER;
203 int idr = icon_mapper.Get().Lookup(group_, icon_size_); 204 int idr = icon_mapper.Get().Lookup(group_, icon_size_);
204 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 205 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
205 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), 206 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(),
206 IconSizeToDIPSize(icon_size_))); 207 IconSizeToDIPSize(icon_size_)));
207 image_skia.MakeThreadSafe(); 208 image_skia.MakeThreadSafe();
208 std::unique_ptr<gfx::Image> image = base::MakeUnique<gfx::Image>(image_skia); 209 std::unique_ptr<gfx::Image> image = base::MakeUnique<gfx::Image>(image_skia);
209 target_task_runner_->PostTask( 210 target_task_runner_->PostTask(
210 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); 211 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_));
211 delete this; 212 delete this;
212 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader_auralinux.cc ('k') | chrome/browser/icon_loader_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698