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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 11441006: Convert IconManager to use new CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix mac compiling Created 8 years 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.h » ('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 #include "chrome/browser/extensions/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/download/download_service_factory.h" 31 #include "chrome/browser/download/download_service_factory.h"
32 #include "chrome/browser/download/download_util.h" 32 #include "chrome/browser/download/download_util.h"
33 #include "chrome/browser/extensions/event_names.h" 33 #include "chrome/browser/extensions/event_names.h"
34 #include "chrome/browser/extensions/event_router.h" 34 #include "chrome/browser/extensions/event_router.h"
35 #include "chrome/browser/extensions/extension_system.h" 35 #include "chrome/browser/extensions/extension_system.h"
36 #include "chrome/browser/icon_loader.h" 36 #include "chrome/browser/icon_loader.h"
37 #include "chrome/browser/icon_manager.h" 37 #include "chrome/browser/icon_manager.h"
38 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 38 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/webui/web_ui_util.h" 40 #include "chrome/browser/ui/webui/web_ui_util.h"
41 #include "chrome/common/cancelable_task_tracker.h"
41 #include "chrome/common/chrome_notification_types.h" 42 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/extensions/api/downloads.h" 43 #include "chrome/common/extensions/api/downloads.h"
43 #include "content/public/browser/download_interrupt_reasons.h" 44 #include "content/public/browser/download_interrupt_reasons.h"
44 #include "content/public/browser/download_item.h" 45 #include "content/public/browser/download_item.h"
45 #include "content/public/browser/download_save_info.h" 46 #include "content/public/browser/download_save_info.h"
46 #include "content/public/browser/download_url_parameters.h" 47 #include "content/public/browser/download_url_parameters.h"
47 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
48 #include "content/public/browser/render_process_host.h" 49 #include "content/public/browser/render_process_host.h"
49 #include "content/public/browser/render_view_host.h" 50 #include "content/public/browser/render_view_host.h"
50 #include "content/public/browser/resource_context.h" 51 #include "content/public/browser/resource_context.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { 222 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor {
222 public: 223 public:
223 DownloadFileIconExtractorImpl() {} 224 DownloadFileIconExtractorImpl() {}
224 225
225 ~DownloadFileIconExtractorImpl() {} 226 ~DownloadFileIconExtractorImpl() {}
226 227
227 virtual bool ExtractIconURLForPath(const FilePath& path, 228 virtual bool ExtractIconURLForPath(const FilePath& path,
228 IconLoader::IconSize icon_size, 229 IconLoader::IconSize icon_size,
229 IconURLCallback callback) OVERRIDE; 230 IconURLCallback callback) OVERRIDE;
230 private: 231 private:
231 void OnIconLoadComplete(IconManager::Handle handle, gfx::Image* icon); 232 void OnIconLoadComplete(gfx::Image* icon);
232 233
233 CancelableRequestConsumer cancelable_consumer_; 234 CancelableTaskTracker cancelable_task_tracker_;
234 IconURLCallback callback_; 235 IconURLCallback callback_;
235 }; 236 };
236 237
237 bool DownloadFileIconExtractorImpl::ExtractIconURLForPath( 238 bool DownloadFileIconExtractorImpl::ExtractIconURLForPath(
238 const FilePath& path, 239 const FilePath& path,
239 IconLoader::IconSize icon_size, 240 IconLoader::IconSize icon_size,
240 IconURLCallback callback) { 241 IconURLCallback callback) {
241 callback_ = callback; 242 callback_ = callback;
242 IconManager* im = g_browser_process->icon_manager(); 243 IconManager* im = g_browser_process->icon_manager();
243 // The contents of the file at |path| may have changed since a previous 244 // The contents of the file at |path| may have changed since a previous
244 // request, in which case the associated icon may also have changed. 245 // request, in which case the associated icon may also have changed.
245 // Therefore, for the moment we always call LoadIcon instead of attempting 246 // Therefore, for the moment we always call LoadIcon instead of attempting
246 // a LookupIcon. 247 // a LookupIcon.
247 im->LoadIcon( 248 im->LoadIcon(path,
248 path, icon_size, &cancelable_consumer_, 249 icon_size,
249 base::Bind(&DownloadFileIconExtractorImpl::OnIconLoadComplete, 250 base::Bind(&DownloadFileIconExtractorImpl::OnIconLoadComplete,
250 base::Unretained(this))); 251 base::Unretained(this)),
252 &cancelable_task_tracker_);
251 return true; 253 return true;
252 } 254 }
253 255
254 void DownloadFileIconExtractorImpl::OnIconLoadComplete( 256 void DownloadFileIconExtractorImpl::OnIconLoadComplete(gfx::Image* icon) {
255 IconManager::Handle handle,
256 gfx::Image* icon) {
257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
258 std::string url; 258 std::string url;
259 if (icon) 259 if (icon)
260 url = web_ui_util::GetBitmapDataUrl(icon->AsBitmap()); 260 url = web_ui_util::GetBitmapDataUrl(icon->AsBitmap());
261 callback_.Run(url); 261 callback_.Run(url);
262 } 262 }
263 263
264 IconLoader::IconSize IconLoaderSizeFromPixelSize(int pixel_size) { 264 IconLoader::IconSize IconLoaderSizeFromPixelSize(int pixel_size) {
265 switch (pixel_size) { 265 switch (pixel_size) {
266 case 16: return IconLoader::SMALL; 266 case 16: return IconLoader::SMALL;
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 if (profile_->HasOffTheRecordProfile() && 991 if (profile_->HasOffTheRecordProfile() &&
992 !profile_->IsOffTheRecord()) { 992 !profile_->IsOffTheRecord()) {
993 DispatchEventInternal( 993 DispatchEventInternal(
994 profile_->GetOffTheRecordProfile(), 994 profile_->GetOffTheRecordProfile(),
995 event_name, 995 event_name,
996 json_args, 996 json_args,
997 scoped_ptr<base::ListValue>(args->DeepCopy())); 997 scoped_ptr<base::ListValue>(args->DeepCopy()));
998 } 998 }
999 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); 999 DispatchEventInternal(profile_, event_name, json_args, args.Pass());
1000 } 1000 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/icon_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698