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

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: 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..00018a3f4809eaecf493d479094d86b20583cc25 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_utils.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,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);
+ // TODO(mek): This used to do caching with ImageLoadingTracker.
+ extension_image_utils::LoadImageAsync(extension_, resource,
+ gfx::Size(size, size),
+ base::Bind(&Application::OnImageLoaded, AsWeakPtr()));
Finnur 2012/10/05 14:41:33 I suggest you add the people who used the CACHE pa
Marijn Kruisselbrink 2012/10/05 18:00:08 It also seems that currently all the places that u
}
BackgroundApplicationListModel::~BackgroundApplicationListModel() {

Powered by Google App Engine
This is Rietveld 408576698