| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |