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

Unified Diff: ui/gfx/image/image.cc

Issue 1769433002: gfx::Image: Refactor to avoid assuming scoped_ptr lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 years, 9 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
« no previous file with comments | « ui/gfx/image/image.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/gfx/image/image.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698