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

Side by Side Diff: chrome/browser/icon_loader_mac.mm

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_chromeos.cc ('k') | chrome/browser/icon_loader_win.cc » ('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 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/task_scheduler/post_task.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/image/image_skia_util_mac.h" 17 #include "ui/gfx/image/image_skia_util_mac.h"
17 18
18 // static 19 // static
19 IconLoader::IconGroup IconLoader::GroupForFilepath( 20 IconLoader::IconGroup IconLoader::GroupForFilepath(
20 const base::FilePath& file_path) { 21 const base::FilePath& file_path) {
21 return file_path.Extension(); 22 return file_path.Extension();
22 } 23 }
23 24
24 // static 25 // static
25 content::BrowserThread::ID IconLoader::ReadIconThreadID() { 26 scoped_refptr<base::TaskRunner> IconLoader::GetReadIconTaskRunner() {
26 return content::BrowserThread::FILE; 27 // NSWorkspace is thread-safe.
28 return base::CreateTaskRunnerWithTraits(traits());
27 } 29 }
28 30
29 void IconLoader::ReadIcon() { 31 void IconLoader::ReadIcon() {
30 NSString* group = base::SysUTF8ToNSString(group_); 32 NSString* group = base::SysUTF8ToNSString(group_);
31 NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; 33 NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
32 NSImage* icon = [workspace iconForFileType:group]; 34 NSImage* icon = [workspace iconForFileType:group];
33 35
34 std::unique_ptr<gfx::Image> image; 36 std::unique_ptr<gfx::Image> image;
35 37
36 if (icon_size_ == ALL) { 38 if (icon_size_ == ALL) {
(...skipping 15 matching lines...) Expand all
52 if (!image_skia.isNull()) { 54 if (!image_skia.isNull()) {
53 image_skia.MakeThreadSafe(); 55 image_skia.MakeThreadSafe();
54 image = base::MakeUnique<gfx::Image>(image_skia); 56 image = base::MakeUnique<gfx::Image>(image_skia);
55 } 57 }
56 } 58 }
57 59
58 target_task_runner_->PostTask( 60 target_task_runner_->PostTask(
59 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); 61 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_));
60 delete this; 62 delete this;
61 } 63 }
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader_chromeos.cc ('k') | chrome/browser/icon_loader_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698