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

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

Issue 12211049: Removing base::ThreadRestrictions::ScopedAllowIO from icon_manager_linux.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review changes. Created 7 years, 10 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
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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "chrome/browser/icon_manager.h"
9 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
10 11
11 #if defined(TOOLKIT_GTK) 12 #if defined(TOOLKIT_GTK)
12 #include "base/nix/mime_util_xdg.h" 13 #include "base/nix/mime_util_xdg.h"
13 #endif 14 #endif
14 15
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 IconLoader::IconLoader(const IconGroupID& group, IconSize size, 18 IconLoader::IconLoader(const base::FilePath& file_path, IconSize size,
18 Delegate* delegate) 19 Delegate* delegate)
19 : target_message_loop_(NULL), 20 : target_message_loop_(NULL),
20 group_(group), 21 file_path_(file_path),
21 icon_size_(size), 22 icon_size_(size),
22 image_(NULL), 23 image_(NULL),
23 delegate_(delegate) { 24 delegate_(delegate) {
24 } 25 }
25 26
26 IconLoader::~IconLoader() { 27 IconLoader::~IconLoader() {
27 } 28 }
28 29
29 void IconLoader::Start() { 30 void IconLoader::Start() {
30 target_message_loop_ = base::MessageLoopProxy::current(); 31 target_message_loop_ = base::MessageLoopProxy::current();
31 32
32 #if defined(TOOLKIT_GTK) 33 #if defined(TOOLKIT_GTK)
33 // This call must happen on the UI thread before we can start loading icons. 34 // This call must happen on the UI thread before we can start loading icons.
34 base::nix::DetectGtkTheme(); 35 base::nix::DetectGtkTheme();
35 #endif 36 #endif
36 37
37 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 38 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
38 base::Bind(&IconLoader::ReadIcon, this)); 39 base::Bind(&IconLoader::ReadGroup, this),
40 base::Bind(&IconLoader::OnReadGroup, this));
41 }
42
43 void IconLoader::ReadGroup() {
44 group_ = IconManager::ReadGroupIDFromFilepath(file_path_);
45 }
46
47 void IconLoader::OnReadGroup() {
48 if (!delegate_->OnGroupLoaded(this, group_)) {
49 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
50 base::Bind(&IconLoader::ReadIcon, this));
51 }
39 } 52 }
40 53
41 void IconLoader::NotifyDelegate() { 54 void IconLoader::NotifyDelegate() {
42 // If the delegate takes ownership of the Image, release it from the scoped 55 // If the delegate takes ownership of the Image, release it from the scoped
43 // pointer. 56 // pointer.
44 if (delegate_->OnImageLoaded(this, image_.get())) 57 if (delegate_->OnImageLoaded(this, image_.get(), group_))
45 ignore_result(image_.release()); // Can't ignore return value. 58 ignore_result(image_.release()); // Can't ignore return value.
46 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698