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

Side by Side Diff: chrome/browser/ui/app_list/search/common/url_icon_source.h

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a few comments Created 5 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/image_decoder.h" 12 #include "chrome/browser/image_decoder.h"
13 #include "net/url_request/url_fetcher_delegate.h" 13 #include "net/url_request/url_fetcher_delegate.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/image/image_skia_source.h" 15 #include "ui/gfx/image/image_skia_source.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace net { 18 namespace net {
19 class URLFetcher; 19 class URLFetcher;
20 class URLRequestContextGetter; 20 class URLRequestContextGetter;
21 } 21 }
22 22
23 namespace app_list { 23 namespace app_list {
24 24
25 // An ImageSkiaSource for icons fetched from a URL. Till the URL icon is 25 // An ImageSkiaSource for icons fetched from a URL. Till the URL icon is
26 // fetched, the default icon (specified by it's resource id) is shown. 26 // fetched, the default icon (specified by it's resource id) is shown.
27 class UrlIconSource : public gfx::ImageSkiaSource, 27 class UrlIconSource : public gfx::ImageSkiaSource,
28 public net::URLFetcherDelegate, 28 public net::URLFetcherDelegate,
29 public ImageDecoder::Delegate { 29 public ImageDecoder::ImageRequest {
30 public: 30 public:
31 typedef base::Closure IconLoadedCallback; 31 typedef base::Closure IconLoadedCallback;
32 32
33 // Create a URL Icon source with the given URL. The post_process parameter 33 // Create a URL Icon source with the given URL. The post_process parameter
34 // specifies a function to post-process the result icon before displaying it. 34 // specifies a function to post-process the result icon before displaying it.
35 UrlIconSource(const IconLoadedCallback& icon_loaded_callback, 35 UrlIconSource(const IconLoadedCallback& icon_loaded_callback,
36 net::URLRequestContextGetter* context_getter, 36 net::URLRequestContextGetter* context_getter,
37 const GURL& icon_url, 37 const GURL& icon_url,
38 int icon_size, 38 int icon_size,
39 int default_icon_resource_id); 39 int default_icon_resource_id);
40 ~UrlIconSource() override; 40 ~UrlIconSource() override;
41 41
42 private: 42 private:
43 // Invoked from GetImageForScale to download the app icon when the hosting 43 // Invoked from GetImageForScale to download the app icon when the hosting
44 // ImageSkia gets painted on screen. 44 // ImageSkia gets painted on screen.
45 void StartIconFetch(); 45 void StartIconFetch();
46 46
47 // gfx::ImageSkiaSource overrides: 47 // gfx::ImageSkiaSource overrides:
48 gfx::ImageSkiaRep GetImageForScale(float scale) override; 48 gfx::ImageSkiaRep GetImageForScale(float scale) override;
49 49
50 // net::URLFetcherDelegate overrides: 50 // net::URLFetcherDelegate overrides:
51 void OnURLFetchComplete(const net::URLFetcher* source) override; 51 void OnURLFetchComplete(const net::URLFetcher* source) override;
52 52
53 // ImageDecoder::Delegate overrides: 53 // ImageDecoder::ImageRequest overrides:
54 void OnImageDecoded(const ImageDecoder* decoder, 54 void OnImageDecoded(const SkBitmap& decoded_image) override;
55 const SkBitmap& decoded_image) override; 55 void OnDecodeImageFailed() override;
56 void OnDecodeImageFailed(const ImageDecoder* decoder) override;
57 56
58 IconLoadedCallback icon_loaded_callback_; 57 IconLoadedCallback icon_loaded_callback_;
59 net::URLRequestContextGetter* context_getter_; 58 net::URLRequestContextGetter* context_getter_;
60 const GURL icon_url_; 59 const GURL icon_url_;
61 const int icon_size_; 60 const int icon_size_;
62 const int default_icon_resource_id_; 61 const int default_icon_resource_id_;
63 62
64 bool icon_fetch_attempted_; 63 bool icon_fetch_attempted_;
65 scoped_ptr<net::URLFetcher> icon_fetcher_; 64 scoped_ptr<net::URLFetcher> icon_fetcher_;
66 65
67 scoped_refptr<ImageDecoder> image_decoder_;
68
69 gfx::ImageSkia icon_; 66 gfx::ImageSkia icon_;
70 67
71 DISALLOW_COPY_AND_ASSIGN(UrlIconSource); 68 DISALLOW_COPY_AND_ASSIGN(UrlIconSource);
72 }; 69 };
73 70
74 } // namespace app_list 71 } // namespace app_list
75 72
76 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_ 73 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_URL_ICON_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_downloader.cc ('k') | chrome/browser/ui/app_list/search/common/url_icon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698