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

Unified Diff: ppapi/host/ppapi_host.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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: ppapi/host/ppapi_host.cc
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
index 0ec37b6e11d2c8ac9ff5a7c96593a5420a1e310e..0934ed82c9a720a7dff5f41ae0494f59768aa5a6 100644
--- a/ppapi/host/ppapi_host.cc
+++ b/ppapi/host/ppapi_host.cc
@@ -136,23 +136,37 @@ void PpapiHost::OnHostMsgResourceCreated(
return;
}
+ if (nested_msg.type() == PpapiHostMsg_Graphics2D_Create::ID)
+ graphics_2d_set_.insert(params.pp_resource());
+
resources_[params.pp_resource()] =
linked_ptr<ResourceHost>(resource_host.release());
}
-void PpapiHost::OnHostMsgResourceDestroyed(PP_Resource resource) {
- ResourceMap::iterator found = resources_.find(resource);
- if (found == resources_.end()) {
+// static
+template <typename Container, typename Element>
+void PpapiHost::ReleaseResource(Container container, Element element) {
+ typename Container::iterator found = container.find(element);
+ if (found == container.end()) {
NOTREACHED();
return;
}
- resources_.erase(found);
+ container.erase(found);
}
-ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) {
- ResourceMap::iterator found = resources_.find(resource);
+void PpapiHost::OnHostMsgResourceDestroyed(PP_Resource resource) {
+ ReleaseResource(resources_, resource);
+ ReleaseResource(graphics_2d_set_, resource);
+}
+
+ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const {
+ ResourceMap::const_iterator found = resources_.find(resource);
return found == resources_.end() ? NULL : found->second.get();
}
+bool PpapiHost::IsGraphics2DResource(PP_Resource resource) const {
+ return graphics_2d_set_.find(resource) != graphics_2d_set_.end();
+}
+
} // namespace host
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698