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 #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 20 matching lines...) Expand all Loading... |
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, gfx::Image* result) = 0; |
48 | 49 |
49 protected: | 50 protected: |
50 virtual ~Delegate() {} | 51 virtual ~Delegate() {} |
51 }; | 52 }; |
52 | 53 |
53 IconLoader(const IconGroupID& group, IconSize size, Delegate* delegate); | 54 IconLoader(const base::FilePath& file_path, |
| 55 IconSize size, |
| 56 Delegate* delegate); |
54 | 57 |
55 // Start reading the icon on the file thread. | 58 // Start reading the icon on the file thread. |
56 void Start(); | 59 void Start(); |
57 | 60 |
58 private: | 61 private: |
59 friend class base::RefCountedThreadSafe<IconLoader>; | 62 friend class base::RefCountedThreadSafe<IconLoader>; |
60 | 63 |
61 virtual ~IconLoader(); | 64 virtual ~IconLoader(); |
62 | 65 |
63 void ReadIcon(); | 66 void ReadIcon(const IconGroupID& group); |
| 67 void ReadGroupAndIcon(); |
64 | 68 |
65 void NotifyDelegate(); | 69 void NotifyDelegate(); |
66 | 70 |
67 // The message loop object of the thread in which we notify the delegate. | 71 // The message loop object of the thread in which we notify the delegate. |
68 scoped_refptr<base::MessageLoopProxy> target_message_loop_; | 72 scoped_refptr<base::MessageLoopProxy> target_message_loop_; |
69 | 73 |
70 IconGroupID group_; | 74 base::FilePath file_path_; |
71 | 75 |
72 IconSize icon_size_; | 76 IconSize icon_size_; |
73 | 77 |
74 scoped_ptr<gfx::Image> image_; | 78 scoped_ptr<gfx::Image> image_; |
75 | 79 |
76 Delegate* delegate_; | 80 Delegate* delegate_; |
77 | 81 |
78 DISALLOW_COPY_AND_ASSIGN(IconLoader); | 82 DISALLOW_COPY_AND_ASSIGN(IconLoader); |
79 }; | 83 }; |
80 | 84 |
81 #endif // CHROME_BROWSER_ICON_LOADER_H_ | 85 #endif // CHROME_BROWSER_ICON_LOADER_H_ |
OLD | NEW |