| Index: ui/base/resource/resource_bundle_gtk.cc
|
| ===================================================================
|
| --- ui/base/resource/resource_bundle_gtk.cc (revision 135347)
|
| +++ ui/base/resource/resource_bundle_gtk.cc (working copy)
|
| @@ -56,7 +56,9 @@
|
| FilePath path;
|
| if (PathService::Get(base::DIR_MODULE, &path))
|
| return path.AppendASCII(pak_name.c_str());
|
| - return FilePath();
|
| +
|
| + // Return just the name of the pack file.
|
| + return FilePath(pak_name.c_str());
|
| }
|
|
|
| } // namespace
|
| @@ -77,33 +79,36 @@
|
| // Check to see if the image is already in the cache.
|
| {
|
| base::AutoLock lock_scope(*images_and_fonts_lock_);
|
| - ImageMap::const_iterator found = images_.find(key);
|
| - if (found != images_.end())
|
| - return *found->second;
|
| + if (images_.count(key))
|
| + return images_[key];
|
| }
|
|
|
| - scoped_refptr<base::RefCountedStaticMemory> data(
|
| - LoadDataResourceBytes(resource_id));
|
| - GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
|
| + gfx::Image image;
|
| + 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.IsEmpty()) {
|
| + 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 = 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))
|
| + return images_[key];
|
| +
|
| + images_[key] = image;
|
| + return images_[key];
|
| }
|
|
|
| } // namespace ui
|
|
|