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

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: 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
« no previous file with comments | « chrome/browser/android/logo_service.cc ('k') | chrome/browser/bitmap_fetcher/bitmap_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7752c8636c09e0795bfa198da8f7c0e8529d8614 100644
--- a/chrome/browser/apps/drive/drive_app_converter.cc
+++ b/chrome/browser/apps/drive/drive_app_converter.cc
@@ -32,18 +32,17 @@ using content::BrowserThread;
// https://developers.google.com/drive/v2/reference/apps#resource
// Each icon url represents a single image associated with a certain size.
class DriveAppConverter::IconFetcher : public net::URLFetcherDelegate,
- public ImageDecoder::Delegate {
+ public ImageDecoder::ImageRequest {
public:
IconFetcher(DriveAppConverter* converter,
const GURL& icon_url,
int expected_size)
- : converter_(converter),
+ : ImageRequest(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)),
+ converter_(converter),
icon_url_(icon_url),
expected_size_(expected_size) {}
- ~IconFetcher() override {
- if (image_decoder_.get())
- image_decoder_->set_delegate(NULL);
- }
+ ~IconFetcher() override {}
void Start() {
fetcher_.reset(
@@ -71,30 +70,23 @@ 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::Start(this, unsafe_icon_data);
}
- // ImageDecoder::Delegate overrides:
- void OnImageDecoded(const ImageDecoder* decoder,
- const SkBitmap& decoded_image) override {
+ // ImageDecoder::ImageRequest overrides:
+ 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);
« no previous file with comments | « chrome/browser/android/logo_service.cc ('k') | chrome/browser/bitmap_fetcher/bitmap_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698