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

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: remove unused code Created 8 years, 2 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/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..52fb00ca4554ce7cd3f46ed7f073fb6341ee55ba 100644
--- a/chrome/browser/background/background_application_list_model.cc
+++ b/chrome/browser/background/background_application_list_model.cc
@@ -16,7 +16,8 @@
#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/extension_system.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 +61,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 +69,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 +78,6 @@ class BackgroundApplicationListModel::Application
const Extension* extension_;
scoped_ptr<gfx::ImageSkia> icon_;
BackgroundApplicationListModel* model_;
- ImageLoadingTracker tracker_;
};
namespace {
@@ -141,14 +139,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 +154,10 @@ 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::ExtensionSystem::Get(model_->profile_)->
+ image_loader()->LoadImageAsync(
+ extension_, resource, gfx::Size(size, size),
+ base::Bind(&Application::OnImageLoaded, AsWeakPtr()));
}
BackgroundApplicationListModel::~BackgroundApplicationListModel() {

Powered by Google App Engine
This is Rietveld 408576698