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

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

Issue 113120: stub impl of linux,mac icon loader/manager (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: style fixes Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/icon_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 13
14 #if defined(OS_WIN)
15 // On Windows, we group files by their extension, with several exceptions:
16 // .dll, .exe, .ico. See IconManager.h for explanation.
17 typedef std::wstring IconGroupID;
18 #elif defined(OS_POSIX)
19 // On POSIX, we group files by MIME type.
20 typedef std::string IconGroupID;
21 #endif
22
23 class MessageLoop;
14 class SkBitmap; 24 class SkBitmap;
15 25
16 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
17 // 27 //
18 // A facility to read a file containing an icon asynchronously in the IO 28 // A facility to read a file containing an icon asynchronously in the IO
19 // thread. Returns the icon in the form of an SkBitmap. 29 // thread. Returns the icon in the form of an SkBitmap.
20 // 30 //
21 //////////////////////////////////////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////////////////////////
22 class IconLoader : public base::RefCountedThreadSafe<IconLoader> { 32 class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
23 public: 33 public:
24 enum IconSize { 34 enum IconSize {
25 SMALL = 0, // 16x16 35 SMALL = 0, // 16x16
26 NORMAL, // 32x32 36 NORMAL, // 32x32
27 LARGE 37 LARGE
28 }; 38 };
29 39
30 class Delegate { 40 class Delegate {
31 public: 41 public:
32 // Invoked when an icon has been read. |source| is the IconLoader. If the 42 // 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 43 // icon has been successfully loaded, result is non-null. This method must
34 // return true if it is taking ownership of the returned bitmap. 44 // return true if it is taking ownership of the returned bitmap.
35 virtual bool OnBitmapLoaded(IconLoader* source, SkBitmap* result) = 0; 45 virtual bool OnBitmapLoaded(IconLoader* source, SkBitmap* result) = 0;
36 }; 46 };
37 47
38 IconLoader() { } 48 IconLoader(const IconGroupID& group, IconSize size, Delegate* delegate);
39 49
40 virtual ~IconLoader() { } 50 virtual ~IconLoader();
41 51
42 // Start reading the icon on the file thread. 52 // Start reading the icon on the file thread.
43 virtual void Start() = 0; 53 void Start();
44
45 // Factory method for returning a platform specific IconLoad.
46 static IconLoader* Create(const FilePath& path, IconSize size,
47 Delegate* delegate);
48 54
49 private: 55 private:
56 void ReadIcon();
57
58 void NotifyDelegate();
59
60 // The message loop object of the thread in which we notify the delegate.
61 MessageLoop* target_message_loop_;
62
63 IconGroupID group_;
64
65 IconSize icon_size_;
66
67 SkBitmap* bitmap_;
68
69 Delegate* delegate_;
70
50 DISALLOW_COPY_AND_ASSIGN(IconLoader); 71 DISALLOW_COPY_AND_ASSIGN(IconLoader);
51 }; 72 };
52 73
53 #endif // CHROME_BROWSER_ICON_LOADER_H_ 74 #endif // CHROME_BROWSER_ICON_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698