| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/resource_tracker.h" | 5 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // pointer will get zeroed out in LastPluginRefWasDeleted. | 116 // pointer will get zeroed out in LastPluginRefWasDeleted. |
| 117 ResourceSet& resource_set = instance_to_resources_[ | 117 ResourceSet& resource_set = instance_to_resources_[ |
| 118 resource->instance()->pp_instance()]; | 118 resource->instance()->pp_instance()]; |
| 119 DCHECK(resource_set.find(res) != resource_set.end()); | 119 DCHECK(resource_set.find(res) != resource_set.end()); |
| 120 resource_set.erase(res); | 120 resource_set.erase(res); |
| 121 | 121 |
| 122 resource->LastPluginRefWasDeleted(true); | 122 resource->LastPluginRefWasDeleted(true); |
| 123 live_resources_.erase(i); | 123 live_resources_.erase(i); |
| 124 } | 124 } |
| 125 | 125 |
| 126 uint32 ResourceTracker::GetLiveObjectsForModule(PluginModule* module) const { | 126 uint32 ResourceTracker::GetLiveObjectsForInstance( |
| 127 // Since this is for testing only, we'll just go through all of them and | 127 PP_Instance instance) const { |
| 128 // count. | 128 InstanceToResourceMap::const_iterator found = |
| 129 // | 129 instance_to_resources_.find(instance); |
| 130 // TODO(brettw) we will eventually need to implement more efficient | 130 if (found == instance_to_resources_.end()) |
| 131 // module->resource lookup to free resources when a module is unloaded. In | 131 return 0; |
| 132 // this case, this function can be implemented using that system. | 132 return static_cast<uint32>(found->second.size()); |
| 133 uint32 count = 0; | |
| 134 for (ResourceMap::const_iterator i = live_resources_.begin(); | |
| 135 i != live_resources_.end(); ++i) | |
| 136 count++; | |
| 137 return count; | |
| 138 } | 133 } |
| 139 | 134 |
| 140 scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const { | 135 scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const { |
| 141 VarMap::const_iterator result = live_vars_.find(var_id); | 136 VarMap::const_iterator result = live_vars_.find(var_id); |
| 142 if (result == live_vars_.end()) { | 137 if (result == live_vars_.end()) { |
| 143 return scoped_refptr<Var>(); | 138 return scoped_refptr<Var>(); |
| 144 } | 139 } |
| 145 return result->second.first; | 140 return result->second.first; |
| 146 } | 141 } |
| 147 | 142 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 258 |
| 264 // static | 259 // static |
| 265 void ResourceTracker::ClearSingletonOverride() { | 260 void ResourceTracker::ClearSingletonOverride() { |
| 266 DCHECK(singleton_override_); | 261 DCHECK(singleton_override_); |
| 267 singleton_override_ = NULL; | 262 singleton_override_ = NULL; |
| 268 } | 263 } |
| 269 | 264 |
| 270 } // namespace ppapi | 265 } // namespace ppapi |
| 271 } // namespace webkit | 266 } // namespace webkit |
| 272 | 267 |
| OLD | NEW |