Index: ui/gfx/image/image.cc |
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc |
index 86cc83a31d48e50ad9bc29a21af2a296a278b09d..a306cc27418b486da3694a396979f0686f4d1ce3 100644 |
--- a/ui/gfx/image/image.cc |
+++ b/ui/gfx/image/image.cc |
@@ -510,8 +510,7 @@ const ImageSkia* Image::ToImageSkia() const { |
NOTREACHED(); |
} |
CHECK(scoped_rep); |
- rep = scoped_rep.get(); |
- AddRepresentation(std::move(scoped_rep)); |
+ rep = AddRepresentation(std::move(scoped_rep)); |
} |
return rep->AsImageRepSkia()->image(); |
} |
@@ -541,8 +540,7 @@ UIImage* Image::ToUIImage() const { |
NOTREACHED(); |
} |
CHECK(scoped_rep); |
- rep = scoped_rep.get(); |
- AddRepresentation(std::move(scoped_rep)); |
+ rep = AddRepresentation(std::move(scoped_rep)); |
} |
return rep->AsImageRepCocoaTouch()->image(); |
} |
@@ -575,8 +573,7 @@ NSImage* Image::ToNSImage() const { |
NOTREACHED(); |
} |
CHECK(scoped_rep); |
- rep = scoped_rep.get(); |
- AddRepresentation(std::move(scoped_rep)); |
+ rep = AddRepresentation(std::move(scoped_rep)); |
} |
return rep->AsImageRepCocoa()->image(); |
} |
@@ -749,7 +746,8 @@ internal::ImageRep* Image::GetRepresentation( |
return it->second.get(); |
} |
-void Image::AddRepresentation(scoped_ptr<internal::ImageRep> rep) const { |
+internal::ImageRep* Image::AddRepresentation( |
+ scoped_ptr<internal::ImageRep> rep) const { |
CHECK(storage_.get()); |
RepresentationType type = rep->type(); |
auto result = |
@@ -758,6 +756,8 @@ void Image::AddRepresentation(scoped_ptr<internal::ImageRep> rep) const { |
// insert should not fail (implies that there was already a representation of |
// that type in the map). |
CHECK(result.second) << "type was already in map."; |
+ |
+ return result.first->second.get(); |
} |
} // namespace gfx |