[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 7ced67af | 2009-04-14 23:25:16 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_ICON_LOADER_H_ |
6 | #define CHROME_BROWSER_ICON_LOADER_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 8 | #include <string> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | |
[email protected] | 56d01f6 | 2009-03-12 22:41:54 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | 7ced67af | 2009-04-14 23:25:16 | [diff] [blame] | 11 | #include "base/file_path.h" |
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 12 | #include "base/ref_counted.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
14 | class SkBitmap; | ||||
15 | |||||
16 | //////////////////////////////////////////////////////////////////////////////// | ||||
17 | // | ||||
18 | // A facility to read a file containing an icon asynchronously in the IO | ||||
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 19 | // thread. Returns the icon in the form of an SkBitmap. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | // |
21 | //////////////////////////////////////////////////////////////////////////////// | ||||
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 22 | class IconLoader : public base::RefCountedThreadSafe<IconLoader> { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 23 | public: |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | enum IconSize { |
25 | SMALL = 0, // 16x16 | ||||
26 | NORMAL, // 32x32 | ||||
27 | LARGE | ||||
28 | }; | ||||
29 | |||||
30 | class Delegate { | ||||
31 | public: | ||||
32 | // Invoked when an icon has been read. |source| is the IconLoader. If the | ||||
33 | // icon has been successfully loaded, result is non-null. This method must | ||||
34 | // return true if it is taking ownership of the returned bitmap. | ||||
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 35 | virtual bool OnBitmapLoaded(IconLoader* source, SkBitmap* result) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 36 | }; |
37 | |||||
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 38 | IconLoader() { } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 39 | |
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 40 | virtual ~IconLoader() { } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | |
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 42 | // Start reading the icon on the file thread. |
43 | virtual void Start() = 0; | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 44 | |
[email protected] | 46728b1f | 2009-05-07 20:42:24 | [diff] [blame] | 45 | // Factory method for returning a platform specific IconLoad. |
46 | static IconLoader* Create(const FilePath& path, IconSize size, | ||||
47 | Delegate* delegate); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 48 | |
49 | private: | ||||
[email protected] | 7ced67af | 2009-04-14 23:25:16 | [diff] [blame] | 50 | DISALLOW_COPY_AND_ASSIGN(IconLoader); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | }; |
52 | |||||
[email protected] | 7ced67af | 2009-04-14 23:25:16 | [diff] [blame] | 53 | #endif // CHROME_BROWSER_ICON_LOADER_H_ |