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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/history/top_sites_database.h ('k') | chrome/browser/icon_manager_android.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) 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 // Class for finding and caching Windows explorer icons. The IconManager 5 // Class for finding and caching Windows explorer icons. The IconManager
6 // lives on the UI thread but performs icon extraction work on the file thread 6 // lives on the UI thread but performs icon extraction work on the file thread
7 // to avoid blocking the UI thread with potentially expensive COM and disk 7 // to avoid blocking the UI thread with potentially expensive COM and disk
8 // operations. 8 // operations.
9 // 9 //
10 // Terminology 10 // Terminology
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 #ifndef CHROME_BROWSER_ICON_MANAGER_H_ 45 #ifndef CHROME_BROWSER_ICON_MANAGER_H_
46 #define CHROME_BROWSER_ICON_MANAGER_H_ 46 #define CHROME_BROWSER_ICON_MANAGER_H_
47 47
48 #include <map> 48 #include <map>
49 49
50 #include "chrome/browser/icon_loader.h" 50 #include "chrome/browser/icon_loader.h"
51 #include "chrome/common/cancelable_task_tracker.h" 51 #include "chrome/common/cancelable_task_tracker.h"
52 #include "ui/gfx/image/image.h" 52 #include "ui/gfx/image/image.h"
53 53
54 namespace base {
54 class FilePath; 55 class FilePath;
56 }
55 57
56 class IconManager : public IconLoader::Delegate { 58 class IconManager : public IconLoader::Delegate {
57 public: 59 public:
58 IconManager(); 60 IconManager();
59 virtual ~IconManager(); 61 virtual ~IconManager();
60 62
61 // Synchronous call to examine the internal caches for the icon. Returns the 63 // Synchronous call to examine the internal caches for the icon. Returns the
62 // icon if we have already loaded it, NULL if we don't have it and must load 64 // icon if we have already loaded it, NULL if we don't have it and must load
63 // it via 'LoadIcon'. The returned bitmap is owned by the IconManager and must 65 // it via 'LoadIcon'. The returned bitmap is owned by the IconManager and must
64 // not be free'd by the caller. If the caller needs to modify the icon, it 66 // not be free'd by the caller. If the caller needs to modify the icon, it
65 // must make a copy and modify the copy. 67 // must make a copy and modify the copy.
66 gfx::Image* LookupIcon(const FilePath& file_name, IconLoader::IconSize size); 68 gfx::Image* LookupIcon(const base::FilePath& file_name, IconLoader::IconSize s ize);
67 69
68 typedef base::Callback<void(gfx::Image*)> IconRequestCallback; 70 typedef base::Callback<void(gfx::Image*)> IconRequestCallback;
69 71
70 // Asynchronous call to lookup and return the icon associated with file. The 72 // Asynchronous call to lookup and return the icon associated with file. The
71 // work is done on the file thread, with the callbacks running on the thread 73 // work is done on the file thread, with the callbacks running on the thread
72 // this function is called. 74 // this function is called.
73 // 75 //
74 // Note: 76 // Note:
75 // 1. This does *not* check the cache. 77 // 1. This does *not* check the cache.
76 // 2. The returned bitmap pointer is *not* owned by callback. So callback 78 // 2. The returned bitmap pointer is *not* owned by callback. So callback
77 // should never keep it or delete it. 79 // should never keep it or delete it.
78 // 3. The gfx::Image pointer passed to the callback may be NULL if decoding 80 // 3. The gfx::Image pointer passed to the callback may be NULL if decoding
79 // failed. 81 // failed.
80 CancelableTaskTracker::TaskId LoadIcon(const FilePath& file_name, 82 CancelableTaskTracker::TaskId LoadIcon(const base::FilePath& file_name,
81 IconLoader::IconSize size, 83 IconLoader::IconSize size,
82 const IconRequestCallback& callback, 84 const IconRequestCallback& callback,
83 CancelableTaskTracker* tracker); 85 CancelableTaskTracker* tracker);
84 86
85 // IconLoader::Delegate interface. 87 // IconLoader::Delegate interface.
86 virtual bool OnImageLoaded(IconLoader* loader, gfx::Image* result) OVERRIDE; 88 virtual bool OnImageLoaded(IconLoader* loader, gfx::Image* result) OVERRIDE;
87 89
88 // Get the identifying string for the given file. The implementation 90 // Get the identifying string for the given file. The implementation
89 // is in icon_manager_[platform].cc. 91 // is in icon_manager_[platform].cc.
90 static IconGroupID GetGroupIDFromFilepath(const FilePath& path); 92 static IconGroupID GetGroupIDFromFilepath(const base::FilePath& path);
91 93
92 private: 94 private:
93 struct CacheKey { 95 struct CacheKey {
94 CacheKey(const IconGroupID& group, IconLoader::IconSize size); 96 CacheKey(const IconGroupID& group, IconLoader::IconSize size);
95 97
96 // Used as a key in the map below, so we need this comparator. 98 // Used as a key in the map below, so we need this comparator.
97 bool operator<(const CacheKey &other) const; 99 bool operator<(const CacheKey &other) const;
98 100
99 IconGroupID group; 101 IconGroupID group;
100 IconLoader::IconSize size; 102 IconLoader::IconSize size;
101 }; 103 };
102 104
103 typedef std::map<CacheKey, gfx::Image*> IconMap; 105 typedef std::map<CacheKey, gfx::Image*> IconMap;
104 IconMap icon_cache_; 106 IconMap icon_cache_;
105 107
106 // Asynchronous requests that have not yet been completed. 108 // Asynchronous requests that have not yet been completed.
107 struct ClientRequest; 109 struct ClientRequest;
108 typedef std::map<IconLoader*, ClientRequest> ClientRequests; 110 typedef std::map<IconLoader*, ClientRequest> ClientRequests;
109 ClientRequests requests_; 111 ClientRequests requests_;
110 112
111 DISALLOW_COPY_AND_ASSIGN(IconManager); 113 DISALLOW_COPY_AND_ASSIGN(IconManager);
112 }; 114 };
113 115
114 #endif // CHROME_BROWSER_ICON_MANAGER_H_ 116 #endif // CHROME_BROWSER_ICON_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_database.h ('k') | chrome/browser/icon_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698