Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 34 public: | 35 public: |
| 35 enum IconSize { | 36 enum IconSize { |
| 36 SMALL = 0, // 16x16 | 37 SMALL = 0, // 16x16 |
| 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: |
| 45 // Invoked when an icon group has been read, but before the icon data | |
| 46 // is read. If the icon is already cached, this method will call and return | |
|
Robert Sesek
2013/02/13 17:33:05
this method will -> this method SHOULD
shatch
2013/02/21 20:02:06
Done.
| |
| 47 // the results of OnImageLoaded with the cached image. Callers of | |
| 48 // this method are expected to skip the subsequent call to OnImageLoaded | |
|
Robert Sesek
2013/02/13 17:33:05
I don't understand this sentence.
shatch
2013/02/21 20:02:06
Done.
| |
| 49 // if this method succeeds. | |
| 50 virtual bool OnGroupLoaded(IconLoader* source, | |
| 51 const IconGroupID& group) = 0; | |
| 44 // Invoked when an icon has been read. |source| is the IconLoader. If the | 52 // 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 | 53 // icon has been successfully loaded, result is non-null. This method must |
| 46 // return true if it is taking ownership of the returned image. | 54 // return true if it is taking ownership of the returned image. |
| 47 virtual bool OnImageLoaded(IconLoader* source, gfx::Image* result) = 0; | 55 virtual bool OnImageLoaded(IconLoader* source, |
| 56 gfx::Image* result, | |
| 57 const IconGroupID& group) = 0; | |
| 48 | 58 |
| 49 protected: | 59 protected: |
| 50 virtual ~Delegate() {} | 60 virtual ~Delegate() {} |
| 51 }; | 61 }; |
| 52 | 62 |
| 53 IconLoader(const IconGroupID& group, IconSize size, Delegate* delegate); | 63 IconLoader(const base::FilePath& file_path, |
| 64 IconSize size, | |
| 65 Delegate* delegate); | |
| 54 | 66 |
| 55 // Start reading the icon on the file thread. | 67 // Start reading the icon on the file thread. |
| 56 void Start(); | 68 void Start(); |
| 57 | 69 |
| 58 private: | 70 private: |
| 59 friend class base::RefCountedThreadSafe<IconLoader>; | 71 friend class base::RefCountedThreadSafe<IconLoader>; |
| 60 | 72 |
| 61 virtual ~IconLoader(); | 73 virtual ~IconLoader(); |
| 62 | 74 |
| 75 void ReadGroup(); | |
| 76 void OnReadGroup(); | |
| 63 void ReadIcon(); | 77 void ReadIcon(); |
| 64 | 78 |
| 65 void NotifyDelegate(); | 79 void NotifyDelegate(); |
| 66 | 80 |
| 67 // The message loop object of the thread in which we notify the delegate. | 81 // The message loop object of the thread in which we notify the delegate. |
| 68 scoped_refptr<base::MessageLoopProxy> target_message_loop_; | 82 scoped_refptr<base::MessageLoopProxy> target_message_loop_; |
| 69 | 83 |
| 84 base::FilePath file_path_; | |
| 85 | |
| 70 IconGroupID group_; | 86 IconGroupID group_; |
| 71 | 87 |
| 72 IconSize icon_size_; | 88 IconSize icon_size_; |
| 73 | 89 |
| 74 scoped_ptr<gfx::Image> image_; | 90 scoped_ptr<gfx::Image> image_; |
| 75 | 91 |
| 76 Delegate* delegate_; | 92 Delegate* delegate_; |
| 77 | 93 |
| 78 DISALLOW_COPY_AND_ASSIGN(IconLoader); | 94 DISALLOW_COPY_AND_ASSIGN(IconLoader); |
| 79 }; | 95 }; |
| 80 | 96 |
| 81 #endif // CHROME_BROWSER_ICON_LOADER_H_ | 97 #endif // CHROME_BROWSER_ICON_LOADER_H_ |
| OLD | NEW |