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

Unified Diff: webkit/plugins/ppapi/resource_tracker.cc

Issue 6493004: Implement basic crash detection and shutdown handling for out of process PPAP... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « webkit/plugins/ppapi/resource_tracker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/resource_tracker.cc
===================================================================
--- webkit/plugins/ppapi/resource_tracker.cc (revision 74733)
+++ webkit/plugins/ppapi/resource_tracker.cc (working copy)
@@ -159,6 +159,64 @@
}
}
+void ResourceTracker::CleanupInstanceData(PP_Instance instance,
+ bool delete_instance) {
+ DLOG_IF(ERROR, !CheckIdType(instance, PP_ID_TYPE_INSTANCE))
+ << instance << " is not a PP_Instance.";
+ InstanceMap::iterator found = instance_map_.find(instance);
+ if (found == instance_map_.end()) {
+ NOTREACHED();
+ return;
+ }
+ InstanceData& data = found->second;
+
+ // Force release all plugin references to resources associated with the
+ // deleted instance.
+ ResourceSet::iterator cur_res = data.resources.begin();
+ while (cur_res != data.resources.end()) {
+ ResourceMap::iterator found_resource = live_resources_.find(*cur_res);
+ if (found_resource == live_resources_.end()) {
+ NOTREACHED();
+ } else {
+ Resource* resource = found_resource->second.first;
+
+ // Must delete from the resource set first since the resource's instance
+ // pointer will get zeroed out in LastPluginRefWasDeleted.
+ resource->LastPluginRefWasDeleted(true);
+ live_resources_.erase(*cur_res);
+ }
+
+ // Iterators to a set are stable so we can iterate the set while the items
+ // are being deleted as long as we're careful not to delete the item we're
+ // holding an iterator to.
+ ResourceSet::iterator current = cur_res++;
+ data.resources.erase(current);
+ }
+ DCHECK(data.resources.empty());
+
+ // Force delete all var references.
+ VarSet::iterator cur_var = data.object_vars.begin();
+ while (cur_var != data.object_vars.end()) {
+ VarSet::iterator current = cur_var++;
+
+ // Tell the corresponding ObjectVar that the instance is gone.
+ PP_Var object_pp_var;
+ object_pp_var.type = PP_VARTYPE_OBJECT;
+ object_pp_var.value.as_id = *current;
+ scoped_refptr<ObjectVar> object_var(ObjectVar::FromPPVar(object_pp_var));
+ if (object_var.get())
+ object_var->InstanceDeleted();
+
+ // Clear the object from the var mapping and the live instance object list.
+ live_vars_.erase(*current);
+ data.object_vars.erase(*current);
+ }
+ DCHECK(data.object_vars.empty());
+
+ if (delete_instance)
+ instance_map_.erase(found);
+}
+
uint32 ResourceTracker::GetLiveObjectsForInstance(
PP_Instance instance) const {
InstanceMap::const_iterator found = instance_map_.find(instance);
@@ -228,59 +286,11 @@
}
void ResourceTracker::InstanceDeleted(PP_Instance instance) {
- DLOG_IF(ERROR, !CheckIdType(instance, PP_ID_TYPE_INSTANCE))
- << instance << " is not a PP_Instance.";
- InstanceMap::iterator found = instance_map_.find(instance);
- if (found == instance_map_.end()) {
- NOTREACHED();
- return;
- }
- InstanceData& data = found->second;
+ CleanupInstanceData(instance, true);
+}
- // Force release all plugin references to resources associated with the
- // deleted instance.
- ResourceSet::iterator cur_res = data.resources.begin();
- while (cur_res != data.resources.end()) {
- ResourceMap::iterator found_resource = live_resources_.find(*cur_res);
- if (found_resource == live_resources_.end()) {
- NOTREACHED();
- } else {
- Resource* resource = found_resource->second.first;
-
- // Must delete from the resource set first since the resource's instance
- // pointer will get zeroed out in LastPluginRefWasDeleted.
- resource->LastPluginRefWasDeleted(true);
- live_resources_.erase(*cur_res);
- }
-
- // Iterators to a set are stable so we can iterate the set while the items
- // are being deleted as long as we're careful not to delete the item we're
- // holding an iterator to.
- ResourceSet::iterator current = cur_res++;
- data.resources.erase(current);
- }
- DCHECK(data.resources.empty());
-
- // Force delete all var references.
- VarSet::iterator cur_var = data.object_vars.begin();
- while (cur_var != data.object_vars.end()) {
- VarSet::iterator current = cur_var++;
-
- // Tell the corresponding ObjectVar that the instance is gone.
- PP_Var object_pp_var;
- object_pp_var.type = PP_VARTYPE_OBJECT;
- object_pp_var.value.as_id = *current;
- scoped_refptr<ObjectVar> object_var(ObjectVar::FromPPVar(object_pp_var));
- if (object_var.get())
- object_var->InstanceDeleted();
-
- // Clear the object from the var mapping and the live instance object list.
- live_vars_.erase(*current);
- data.object_vars.erase(*current);
- }
- DCHECK(data.object_vars.empty());
-
- instance_map_.erase(found);
+void ResourceTracker::InstanceCrashed(PP_Instance instance) {
+ CleanupInstanceData(instance, false);
}
PluginInstance* ResourceTracker::GetInstance(PP_Instance instance) {
« no previous file with comments | « webkit/plugins/ppapi/resource_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698