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

Unified Diff: ui/base/resource/resource_bundle_gtk.cc

Issue 10270023: Add new ResourceBundle::Delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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: ui/base/resource/resource_bundle_gtk.cc
===================================================================
--- ui/base/resource/resource_bundle_gtk.cc (revision 133962)
+++ ui/base/resource/resource_bundle_gtk.cc (working copy)
@@ -63,28 +63,34 @@
return *found->second;
}
- scoped_refptr<base::RefCountedStaticMemory> data(
- LoadDataResourceBytes(resource_id));
- GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
+ gfx::Image* image = NULL;
+ if (delegate_)
+ image = delegate_->GetNativeImageNamed(resource_id, rtl);
- // The load was successful, so cache the image.
- if (pixbuf) {
- base::AutoLock lock_scope(*images_and_fonts_lock_);
+ if (!image) {
+ scoped_refptr<base::RefCountedStaticMemory> data(
+ LoadDataResourceBytes(resource_id));
+ GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
- // Another thread raced the load and has already cached the image.
- if (images_.count(key)) {
- g_object_unref(pixbuf);
- return *images_[key];
+ if (!pixbuf) {
+ LOG(WARNING) << "Unable to load pixbuf with id " << resource_id;
+ NOTREACHED(); // Want to assert in debug mode.
+ return *GetEmptyImage();
}
- gfx::Image* image = new gfx::Image(pixbuf); // Takes ownership.
- images_[key] = image;
- return *image;
+ image = new gfx::Image(pixbuf); // Takes ownership.
}
- LOG(WARNING) << "Unable to pixbuf with id " << resource_id;
- NOTREACHED(); // Want to assert in debug mode.
- return *GetEmptyImage();
+ base::AutoLock lock_scope(*images_and_fonts_lock_);
+
+ // Another thread raced the load and has already cached the image.
+ if (images_.count(key)) {
+ delete image;
sail 2012/04/30 21:14:43 instead of doing a delete here, can you use a scop
Marshall 2012/04/30 21:50:10 Done.
+ return *images_[key];
+ }
+
+ images_[key] = image;
+ return *image;
}
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698