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 #ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 // See SetSingletonOverride above. | 169 // See SetSingletonOverride above. |
170 static ResourceTracker* singleton_override_; | 170 static ResourceTracker* singleton_override_; |
171 | 171 |
172 // Last assigned resource & var ID. | 172 // Last assigned resource & var ID. |
173 PP_Resource last_resource_id_; | 173 PP_Resource last_resource_id_; |
174 int32 last_var_id_; | 174 int32 last_var_id_; |
175 | 175 |
176 // For each PP_Resource, keep the Resource* (as refptr) and plugin use count. | 176 // For each PP_Resource, keep the Resource* (as refptr) and plugin use count. |
177 // This use count is different then Resource's RefCount, and is manipulated | 177 // This use count is different then Resource's RefCount, and is manipulated |
178 // using this RefResource/UnrefResource. When it drops to zero, we just remove | 178 // using this AddRefResource/UnrefResource. When it drops to zero, we just |
179 // the resource from this resource tracker, but the resource object will be | 179 // remove the resource from this resource tracker, but the resource object |
180 // alive so long as some scoped_refptr still holds it's reference. This | 180 // will be alive so long as some scoped_refptr still holds it's |
181 // prevents plugins from forcing destruction of Resource objects. | 181 // reference. This prevents plugins from forcing destruction of Resource |
| 182 // objects. |
182 typedef std::pair<scoped_refptr<Resource>, size_t> ResourceAndRefCount; | 183 typedef std::pair<scoped_refptr<Resource>, size_t> ResourceAndRefCount; |
183 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; | 184 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; |
184 ResourceMap live_resources_; | 185 ResourceMap live_resources_; |
185 | 186 |
186 // Like ResourceAndRefCount but for vars, which are associated with modules. | 187 // Like ResourceAndRefCount but for vars, which are associated with modules. |
187 typedef std::pair<scoped_refptr<Var>, size_t> VarAndRefCount; | 188 typedef std::pair<scoped_refptr<Var>, size_t> VarAndRefCount; |
188 typedef base::hash_map<int32, VarAndRefCount> VarMap; | 189 typedef base::hash_map<int32, VarAndRefCount> VarMap; |
189 VarMap live_vars_; | 190 VarMap live_vars_; |
190 | 191 |
191 // Tracks all live instances and their associated data. | 192 // Tracks all live instances and their associated data. |
192 typedef std::map<PP_Instance, linked_ptr<InstanceData> > InstanceMap; | 193 typedef std::map<PP_Instance, linked_ptr<InstanceData> > InstanceMap; |
193 InstanceMap instance_map_; | 194 InstanceMap instance_map_; |
194 | 195 |
195 // Tracks all live modules. The pointers are non-owning, the PluginModule | 196 // Tracks all live modules. The pointers are non-owning, the PluginModule |
196 // destructor will notify us when the module is deleted. | 197 // destructor will notify us when the module is deleted. |
197 typedef std::map<PP_Module, PluginModule*> ModuleMap; | 198 typedef std::map<PP_Module, PluginModule*> ModuleMap; |
198 ModuleMap module_map_; | 199 ModuleMap module_map_; |
199 | 200 |
200 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 201 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
201 }; | 202 }; |
202 | 203 |
203 } // namespace ppapi | 204 } // namespace ppapi |
204 } // namespace webkit | 205 } // namespace webkit |
205 | 206 |
206 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ | 207 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
OLD | NEW |