Chromium Code Reviews| 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 |