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

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

Issue 8068013: Add interface to CancelableRequest that allows use of base::Callback<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address brett's comments. Created 9 years, 2 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 | « no previous file | chrome/browser/icon_manager.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Synchronous call to examine the internal caches for the icon. Returns the 65 // Synchronous call to examine the internal caches for the icon. Returns the
66 // icon if we have already loaded it, NULL if we don't have it and must load 66 // icon if we have already loaded it, NULL if we don't have it and must load
67 // it via 'LoadIcon'. The returned bitmap is owned by the IconManager and must 67 // it via 'LoadIcon'. The returned bitmap is owned by the IconManager and must
68 // not be free'd by the caller. If the caller needs to modify the icon, it 68 // not be free'd by the caller. If the caller needs to modify the icon, it
69 // must make a copy and modify the copy. 69 // must make a copy and modify the copy.
70 gfx::Image* LookupIcon(const FilePath& file_name, 70 gfx::Image* LookupIcon(const FilePath& file_name,
71 IconLoader::IconSize size); 71 IconLoader::IconSize size);
72 72
73 typedef CancelableRequestProvider::Handle Handle; 73 typedef CancelableRequestProvider::Handle Handle;
74 typedef Callback2<Handle, gfx::Image*>::Type IconRequestCallback; 74 typedef base::Callback<void(Handle, gfx::Image*)> IconRequestCallback;
75 75
76 // Asynchronous call to lookup and return the icon associated with file. The 76 // Asynchronous call to lookup and return the icon associated with file. The
77 // work is done on the file thread, with the callbacks running on the UI 77 // work is done on the file thread, with the callbacks running on the UI
78 // thread. The return value is the 'request_id' that will be passed to the 78 // thread. The return value is the 'request_id' that will be passed to the
79 // client in the callback. Note: this does *not* check the cache. 79 // client in the callback. Note: this does *not* check the cache.
80 // 80 //
81 // WATCH OUT: The returned bitmap pointer may be NULL if decoding failed. 81 // WATCH OUT: The returned bitmap pointer may be NULL if decoding failed.
82 Handle LoadIcon(const FilePath& file_name, 82 Handle LoadIcon(const FilePath& file_name,
83 IconLoader::IconSize size, 83 IconLoader::IconSize size,
84 CancelableRequestConsumerBase* consumer, 84 CancelableRequestConsumerBase* consumer,
85 IconRequestCallback* callback); 85 const IconRequestCallback& callback);
86 86
87 // IconLoader::Delegate interface. 87 // IconLoader::Delegate interface.
88 virtual bool OnImageLoaded(IconLoader* source, gfx::Image* result); 88 virtual bool OnImageLoaded(IconLoader* source, gfx::Image* result);
89 89
90 // Get the identifying string for the given file. The implementation 90 // Get the identifying string for the given file. The implementation
91 // is in icon_manager_[platform].cc. 91 // is in icon_manager_[platform].cc.
92 static IconGroupID GetGroupIDFromFilepath(const FilePath& path); 92 static IconGroupID GetGroupIDFromFilepath(const FilePath& path);
93 93
94 private: 94 private:
95 struct CacheKey { 95 struct CacheKey {
(...skipping 13 matching lines...) Expand all
109 109
110 // Asynchronous requests that have not yet been completed. 110 // Asynchronous requests that have not yet been completed.
111 struct ClientRequest; 111 struct ClientRequest;
112 typedef std::map<IconLoader*, ClientRequest> ClientRequests; 112 typedef std::map<IconLoader*, ClientRequest> ClientRequests;
113 ClientRequests requests_; 113 ClientRequests requests_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(IconManager); 115 DISALLOW_COPY_AND_ASSIGN(IconManager);
116 }; 116 };
117 117
118 #endif // CHROME_BROWSER_ICON_MANAGER_H_ 118 #endif // CHROME_BROWSER_ICON_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/icon_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698