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

Unified Diff: chrome/browser/apps/drive/drive_app_converter.cc

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ImageDecoder->RemoveDelegate 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/apps/drive/drive_app_converter.cc
diff --git a/chrome/browser/apps/drive/drive_app_converter.cc b/chrome/browser/apps/drive/drive_app_converter.cc
index daaa24d3ee63aadf8caedcb54523dc4243d84c76..1d30b36c1c3fe1e9d2f285e000e5568f4a92919c 100644
--- a/chrome/browser/apps/drive/drive_app_converter.cc
+++ b/chrome/browser/apps/drive/drive_app_converter.cc
@@ -41,8 +41,7 @@ class DriveAppConverter::IconFetcher : public net::URLFetcherDelegate,
icon_url_(icon_url),
expected_size_(expected_size) {}
~IconFetcher() override {
- if (image_decoder_.get())
- image_decoder_->set_delegate(NULL);
+ ImageDecoder::GetInstance()->RemoveDelegate(this);
}
void Start() {
@@ -71,30 +70,25 @@ class DriveAppConverter::IconFetcher : public net::URLFetcherDelegate,
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::GetInstance()->Start(
+ this, unsafe_icon_data, ImageDecoder::DEFAULT_CODEC,
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), false);
}
// ImageDecoder::Delegate overrides:
- void OnImageDecoded(const ImageDecoder* decoder,
- const SkBitmap& decoded_image) override {
+ void OnImageDecoded(const SkBitmap& decoded_image) override {
if (decoded_image.width() == expected_size_)
icon_ = decoded_image;
converter_->OnIconFetchComplete(this);
}
- void OnDecodeImageFailed(const ImageDecoder* decoder) override {
- converter_->OnIconFetchComplete(this);
- }
+ void OnDecodeImageFailed() override { converter_->OnIconFetchComplete(this); }
DriveAppConverter* converter_;
const GURL icon_url_;
const int expected_size_;
scoped_ptr<net::URLFetcher> fetcher_;
- scoped_refptr<ImageDecoder> image_decoder_;
SkBitmap icon_;
DISALLOW_COPY_AND_ASSIGN(IconFetcher);

Powered by Google App Engine
This is Rietveld 408576698