Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/host_var_tracker.h" | 5 #include "webkit/plugins/ppapi/host_var_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "webkit/plugins/ppapi/host_array_buffer_var.h" | 9 #include "webkit/plugins/ppapi/host_array_buffer_var.h" |
| 10 #include "webkit/plugins/ppapi/npobject_var.h" | 10 #include "webkit/plugins/ppapi/npobject_var.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 return 0; | 91 return 0; |
| 92 return static_cast<int>(found->second->size()); | 92 return static_cast<int>(found->second->size()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void HostVarTracker::ForceFreeNPObjectsForInstance(PP_Instance instance) { | 95 void HostVarTracker::ForceFreeNPObjectsForInstance(PP_Instance instance) { |
| 96 InstanceMap::iterator found_instance = instance_map_.find(instance); | 96 InstanceMap::iterator found_instance = instance_map_.find(instance); |
| 97 if (found_instance == instance_map_.end()) | 97 if (found_instance == instance_map_.end()) |
| 98 return; // Nothing to do. | 98 return; // Nothing to do. |
| 99 NPObjectToNPObjectVarMap* np_object_map = found_instance->second.get(); | 99 NPObjectToNPObjectVarMap* np_object_map = found_instance->second.get(); |
| 100 | 100 |
| 101 // Force delete all var references. Need to make a copy so we can iterate over | 101 NPObjectToNPObjectVarMap::iterator cur_var = np_object_map->begin(); |
| 102 // the map while deleting stuff from it. | 102 while (cur_var != np_object_map->end()) { |
| 103 NPObjectToNPObjectVarMap np_object_map_copy = *np_object_map; | |
|
dmichael (off chromium)
2012/02/17 22:45:10
I realized this copy really *is* necessary (now).
| |
| 104 NPObjectToNPObjectVarMap::iterator cur_var = | |
| 105 np_object_map_copy.begin(); | |
| 106 while (cur_var != np_object_map_copy.end()) { | |
| 107 NPObjectToNPObjectVarMap::iterator current = cur_var++; | 103 NPObjectToNPObjectVarMap::iterator current = cur_var++; |
| 108 current->second->InstanceDeleted(); | 104 current->second->InstanceDeleted(); |
| 109 np_object_map->erase(current->first); | 105 ForceReleaseNPObject(current->second); |
| 106 np_object_map->erase(current); | |
| 110 } | 107 } |
| 111 | 108 |
| 112 // Remove the record for this instance since it should be empty. | 109 // Remove the record for this instance since it should be empty. |
| 113 DCHECK(np_object_map->empty()); | 110 DCHECK(np_object_map->empty()); |
|
dmichael (off chromium)
2012/02/17 22:45:10
Note that as-is, PPP_Class_Deallocate could create
| |
| 114 instance_map_.erase(found_instance); | 111 instance_map_.erase(found_instance); |
| 115 } | 112 } |
| 116 | 113 |
| 114 void HostVarTracker::ForceReleaseNPObject(::ppapi::NPObjectVar* object) { | |
| 115 VarMap::iterator iter = live_vars_.find(object->GetExistingVarID()); | |
| 116 if (iter == live_vars_.end()) { | |
| 117 NOTREACHED(); | |
| 118 return; | |
| 119 } | |
| 120 iter->second.ref_count = 0; | |
| 121 DCHECK(iter->second.track_with_no_reference_count == 0); | |
| 122 DeleteObjectInfoIfNecessary(iter); | |
| 123 } | |
| 124 | |
| 117 } // namespace ppapi | 125 } // namespace ppapi |
| 118 } // namespace webkit | 126 } // namespace webkit |
| OLD | NEW |