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

Unified Diff: chrome/browser/ui/app_list/search/common/url_icon_source.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/common/url_icon_source.cc
diff --git a/chrome/browser/ui/app_list/search/common/url_icon_source.cc b/chrome/browser/ui/app_list/search/common/url_icon_source.cc
index acb2d288161215d7f30c4116502206bba80ba149..3dccf5336728f4502a1c11dc26fad9a0051d6c38 100644
--- a/chrome/browser/ui/app_list/search/common/url_icon_source.cc
+++ b/chrome/browser/ui/app_list/search/common/url_icon_source.cc
@@ -17,13 +17,14 @@ using content::BrowserThread;
namespace app_list {
-UrlIconSource::UrlIconSource(
- const IconLoadedCallback& icon_loaded_callback,
- net::URLRequestContextGetter* context_getter,
- const GURL& icon_url,
- int icon_size,
- int default_icon_resource_id)
- : icon_loaded_callback_(icon_loaded_callback),
+UrlIconSource::UrlIconSource(const IconLoadedCallback& icon_loaded_callback,
+ net::URLRequestContextGetter* context_getter,
+ const GURL& icon_url,
+ int icon_size,
+ int default_icon_resource_id)
+ : ImageRequest(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)),
+ icon_loaded_callback_(icon_loaded_callback),
context_getter_(context_getter),
icon_url_(icon_url),
icon_size_(icon_size),
@@ -33,8 +34,6 @@ UrlIconSource::UrlIconSource(
}
UrlIconSource::~UrlIconSource() {
- if (image_decoder_.get())
- image_decoder_->set_delegate(NULL);
}
void UrlIconSource::StartIconFetch() {
@@ -72,14 +71,10 @@ void UrlIconSource::OnURLFetchComplete(
std::string unsafe_icon_data;
fetcher->GetResponseAsString(&unsafe_icon_data);
- image_decoder_ =
- new ImageDecoder(this, unsafe_icon_data, ImageDecoder::DEFAULT_CODEC);
- image_decoder_->Start(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI));
+ ImageDecoder::Start(this, unsafe_icon_data);
}
-void UrlIconSource::OnImageDecoded(const ImageDecoder* decoder,
- const SkBitmap& decoded_image) {
+void UrlIconSource::OnImageDecoded(const SkBitmap& decoded_image) {
icon_ = gfx::ImageSkiaOperations::CreateResizedImage(
gfx::ImageSkia::CreateFrom1xBitmap(decoded_image),
skia::ImageOperations::RESIZE_BEST,
@@ -88,8 +83,7 @@ void UrlIconSource::OnImageDecoded(const ImageDecoder* decoder,
icon_loaded_callback_.Run();
}
-void UrlIconSource::OnDecodeImageFailed(
- const ImageDecoder* decoder) {
+void UrlIconSource::OnDecodeImageFailed() {
// Failed to decode image. Do nothing and just use the default icon.
}

Powered by Google App Engine
This is Rietveld 408576698