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 |