| Index: chrome/browser/icon_loader.h
|
| diff --git a/chrome/browser/icon_loader.h b/chrome/browser/icon_loader.h
|
| index 33301acd8295a62cb3455663942c2ad3f6f0c4f6..642d4e9c076a19d5ed9b928af00b5e7e5039ef4f 100644
|
| --- a/chrome/browser/icon_loader.h
|
| +++ b/chrome/browser/icon_loader.h
|
| @@ -16,15 +16,6 @@
|
| #include "content/public/browser/browser_thread.h"
|
| #include "ui/gfx/image/image.h"
|
|
|
| -#if defined(OS_WIN)
|
| -// On Windows, we group files by their extension, with several exceptions:
|
| -// .dll, .exe, .ico. See IconManager.h for explanation.
|
| -typedef std::wstring IconGroupID;
|
| -#elif defined(OS_POSIX)
|
| -// On POSIX, we group files by MIME type.
|
| -typedef std::string IconGroupID;
|
| -#endif
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
| //
|
| // A facility to read a file containing an icon asynchronously in the IO
|
| @@ -33,6 +24,13 @@ typedef std::string IconGroupID;
|
| ////////////////////////////////////////////////////////////////////////////////
|
| class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
|
| public:
|
| + // An IconGroup is a class of files that all share the same icon. For all
|
| + // platforms but Windows, and for most files on Windows, it is the file type
|
| + // (e.g. all .mp3 files share an icon, all .html files share an icon). For
|
| + // Windows, certain file types (.exe, .dll, etc) are assumed to have a unique
|
| + // icon. In that case, each of those files is a group to itself.
|
| + using IconGroup = base::FilePath::StringType;
|
| +
|
| enum IconSize {
|
| SMALL = 0, // 16x16
|
| NORMAL, // 32x32
|
| @@ -42,25 +40,21 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
|
|
|
| class Delegate {
|
| public:
|
| - // Invoked when an icon group has been read, but before the icon data
|
| - // is read. If the icon is already cached, this method should call and
|
| - // return the results of OnImageLoaded with the cached image.
|
| - virtual bool OnGroupLoaded(IconLoader* source,
|
| - const IconGroupID& group) = 0;
|
| // Invoked when an icon has been read. |source| is the IconLoader. If the
|
| - // icon has been successfully loaded, result is non-null. This method must
|
| - // return true if it is taking ownership of the returned image.
|
| - virtual bool OnImageLoaded(IconLoader* source,
|
| - gfx::Image* result,
|
| - const IconGroupID& group) = 0;
|
| + // icon has been successfully loaded, |result| is non-null. |group| is the
|
| + // determined group from the original requested path.
|
| + virtual void OnImageLoaded(IconLoader* source,
|
| + std::unique_ptr<gfx::Image> result,
|
| + const IconGroup& group) = 0;
|
|
|
| protected:
|
| virtual ~Delegate() {}
|
| };
|
|
|
| - IconLoader(const base::FilePath& file_path,
|
| - IconSize size,
|
| - Delegate* delegate);
|
| + IconLoader(const IconGroup& group, IconSize size, Delegate* delegate);
|
| +
|
| + // Given a file path, get the group for the given file.
|
| + static IconGroup GroupForFilepath(const base::FilePath& path);
|
|
|
| // Start reading the icon on the file thread.
|
| void Start();
|
| @@ -70,18 +64,9 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
|
|
|
| virtual ~IconLoader();
|
|
|
| - // Get the identifying string for the given file. The implementation
|
| - // is in icon_loader_[platform].cc.
|
| - static IconGroupID ReadGroupIDFromFilepath(const base::FilePath& path);
|
| -
|
| - // Some icons (exe's on windows) can change as they're loaded.
|
| - static bool IsIconMutableFromFilepath(const base::FilePath& path);
|
| -
|
| // The thread ReadIcon() should be called on.
|
| static content::BrowserThread::ID ReadIconThreadID();
|
|
|
| - void ReadGroup();
|
| - void OnReadGroup();
|
| void ReadIcon();
|
|
|
| void NotifyDelegate();
|
| @@ -89,9 +74,7 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
|
| // The task runner object of the thread in which we notify the delegate.
|
| scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_;
|
|
|
| - base::FilePath file_path_;
|
| -
|
| - IconGroupID group_;
|
| + IconGroup group_;
|
|
|
| IconSize icon_size_;
|
|
|
|
|