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

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

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 #ifndef CHROME_BROWSER_ICON_LOADER_H_ 5 #ifndef CHROME_BROWSER_ICON_LOADER_H_
6 #define CHROME_BROWSER_ICON_LOADER_H_ 6 #define CHROME_BROWSER_ICON_LOADER_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop_proxy.h" 16 #include "base/message_loop_proxy.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 // On Windows, we group files by their extension, with several exceptions: 20 // On Windows, we group files by their extension, with several exceptions:
20 // .dll, .exe, .ico. See IconManager.h for explanation. 21 // .dll, .exe, .ico. See IconManager.h for explanation.
21 typedef std::wstring IconGroupID; 22 typedef std::wstring IconGroupID;
22 #elif defined(OS_POSIX) 23 #elif defined(OS_POSIX)
(...skipping 14 matching lines...) Expand all
37 NORMAL, // 32x32 38 NORMAL, // 32x32
38 LARGE, // Windows: 32x32, Linux: 48x48, Mac: Unsupported 39 LARGE, // Windows: 32x32, Linux: 48x48, Mac: Unsupported
39 ALL, // All sizes available 40 ALL, // All sizes available
40 }; 41 };
41 42
42 class Delegate { 43 class Delegate {
43 public: 44 public:
44 // Invoked when an icon has been read. |source| is the IconLoader. If the 45 // Invoked when an icon has been read. |source| is the IconLoader. If the
45 // icon has been successfully loaded, result is non-null. This method must 46 // icon has been successfully loaded, result is non-null. This method must
46 // return true if it is taking ownership of the returned image. 47 // return true if it is taking ownership of the returned image.
47 virtual bool OnImageLoaded(IconLoader* source, gfx::Image* result) = 0; 48 virtual bool OnImageLoaded(IconLoader* source,
49 gfx::Image* result,
50 const IconGroupID& group) = 0;
51
52 // Invoked when an icon group has been read, but before the icon data
53 // is read. If the icon is already cached, this method returns true.
Robert Sesek 2013/02/12 16:49:25 What does this class do if the method returns true
shatch 2013/02/13 16:14:52 Done.
54 virtual bool OnGroupLoaded(IconLoader* source,
Robert Sesek 2013/02/12 16:49:25 Since this happens before OnImageLoaded, put it be
shatch 2013/02/13 16:14:52 Done.
55 const IconGroupID& group) = 0;
48 56
49 protected: 57 protected:
50 virtual ~Delegate() {} 58 virtual ~Delegate() {}
51 }; 59 };
52 60
53 IconLoader(const IconGroupID& group, IconSize size, Delegate* delegate); 61 IconLoader(const base::FilePath& file_path,
62 IconSize size,
63 Delegate* delegate);
54 64
55 // Start reading the icon on the file thread. 65 // Start reading the icon on the file thread.
56 void Start(); 66 void Start();
57 67
58 private: 68 private:
59 friend class base::RefCountedThreadSafe<IconLoader>; 69 friend class base::RefCountedThreadSafe<IconLoader>;
60 70
61 virtual ~IconLoader(); 71 virtual ~IconLoader();
62 72
63 void ReadIcon(); 73 void ReadIcon(const IconGroupID& group);
74 void ReadGroup(IconGroupID* group);
Robert Sesek 2013/02/12 16:49:25 Same comment about ordering.
shatch 2013/02/13 16:14:52 Done.
75 void OnReadGroup(const IconGroupID* group);
64 76
65 void NotifyDelegate(); 77 void NotifyDelegate(const IconGroupID& group);
66 78
67 // The message loop object of the thread in which we notify the delegate. 79 // The message loop object of the thread in which we notify the delegate.
68 scoped_refptr<base::MessageLoopProxy> target_message_loop_; 80 scoped_refptr<base::MessageLoopProxy> target_message_loop_;
69 81
70 IconGroupID group_; 82 base::FilePath file_path_;
71 83
72 IconSize icon_size_; 84 IconSize icon_size_;
73 85
74 scoped_ptr<gfx::Image> image_; 86 scoped_ptr<gfx::Image> image_;
75 87
76 Delegate* delegate_; 88 Delegate* delegate_;
77 89
78 DISALLOW_COPY_AND_ASSIGN(IconLoader); 90 DISALLOW_COPY_AND_ASSIGN(IconLoader);
79 }; 91 };
80 92
81 #endif // CHROME_BROWSER_ICON_LOADER_H_ 93 #endif // CHROME_BROWSER_ICON_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698