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

Unified Diff: chrome/browser/background/background_application_list_model.cc

Issue 11027044: Add a class to replace ImageLoadingTracker with a nicer API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix include order Created 8 years, 1 month 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/background/background_application_list_model.cc
diff --git a/chrome/browser/background/background_application_list_model.cc b/chrome/browser/background/background_application_list_model.cc
index e0c6010b6ff1f608cc3f3bcf85080be4aef3d8d4..3b2faf07a2ef2581f3f4f3236ff0b3d1790c7bad 100644
--- a/chrome/browser/background/background_application_list_model.cc
+++ b/chrome/browser/background/background_application_list_model.cc
@@ -16,7 +16,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/image_loading_tracker.h"
+#include "chrome/browser/extensions/image_loader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
@@ -60,7 +60,7 @@ bool ExtensionNameComparator::operator()(const Extension* x,
// Background application representation, private to the
// BackgroundApplicationListModel class.
class BackgroundApplicationListModel::Application
- : public ImageLoadingTracker::Observer {
+ : public base::SupportsWeakPtr<Application> {
public:
Application(BackgroundApplicationListModel* model,
const Extension* an_extension);
@@ -68,9 +68,7 @@ class BackgroundApplicationListModel::Application
virtual ~Application();
// Invoked when a request icon is available.
- virtual void OnImageLoaded(const gfx::Image& image,
- const std::string& extension_id,
- int index) OVERRIDE;
+ void OnImageLoaded(const gfx::Image& image);
// Uses the FILE thread to request this extension's icon, sized
// appropriately.
@@ -79,7 +77,6 @@ class BackgroundApplicationListModel::Application
const Extension* extension_;
scoped_ptr<gfx::ImageSkia> icon_;
BackgroundApplicationListModel* model_;
- ImageLoadingTracker tracker_;
};
namespace {
@@ -141,14 +138,11 @@ BackgroundApplicationListModel::Application::Application(
const Extension* extension)
: extension_(extension),
icon_(NULL),
- model_(model),
- ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
+ model_(model) {
}
void BackgroundApplicationListModel::Application::OnImageLoaded(
- const gfx::Image& image,
- const std::string& extension_id,
- int index) {
+ const gfx::Image& image) {
if (image.IsEmpty())
return;
icon_.reset(image.CopyImageSkia());
@@ -159,8 +153,9 @@ void BackgroundApplicationListModel::Application::RequestIcon(
extension_misc::ExtensionIcons size) {
ExtensionResource resource = extension_->GetIconResource(
size, ExtensionIconSet::MATCH_BIGGER);
- tracker_.LoadImage(extension_, resource, gfx::Size(size, size),
- ImageLoadingTracker::CACHE);
+ extensions::ImageLoader::Get(model_->profile_)->LoadImageAsync(
+ extension_, resource, gfx::Size(size, size),
+ base::Bind(&Application::OnImageLoaded, AsWeakPtr()));
}
BackgroundApplicationListModel::~BackgroundApplicationListModel() {

Powered by Google App Engine
This is Rietveld 408576698