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 #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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // PP_Instances -------------------------------------------------------------- | 80 // PP_Instances -------------------------------------------------------------- |
81 | 81 |
82 // Adds a new plugin instance to the list of tracked instances, and returns a | 82 // Adds a new plugin instance to the list of tracked instances, and returns a |
83 // new instance handle to identify it. | 83 // new instance handle to identify it. |
84 PP_Instance AddInstance(PluginInstance* instance); | 84 PP_Instance AddInstance(PluginInstance* instance); |
85 | 85 |
86 // Called when a plugin instance was deleted and should no longer be tracked. | 86 // Called when a plugin instance was deleted and should no longer be tracked. |
87 // The given handle should be one generated by AddInstance. | 87 // The given handle should be one generated by AddInstance. |
88 void InstanceDeleted(PP_Instance instance); | 88 void InstanceDeleted(PP_Instance instance); |
89 | 89 |
| 90 void InstanceCrashed(PP_Instance instance); |
| 91 |
90 // Returns a pointer to the plugin instance object associated with the given | 92 // Returns a pointer to the plugin instance object associated with the given |
91 // instance handle. The return value will be NULL if the handle is invalid. | 93 // instance handle. The return value will be NULL if the handle is invalid or |
| 94 // if the instance has crashed. |
92 PluginInstance* GetInstance(PP_Instance instance); | 95 PluginInstance* GetInstance(PP_Instance instance); |
93 | 96 |
94 private: | 97 private: |
95 friend struct base::DefaultLazyInstanceTraits<ResourceTracker>; | 98 friend struct base::DefaultLazyInstanceTraits<ResourceTracker>; |
96 friend class Resource; | 99 friend class Resource; |
97 friend class ResourceTrackerTest; | 100 friend class ResourceTrackerTest; |
98 friend class Var; | 101 friend class Var; |
99 | 102 |
100 typedef std::set<PP_Resource> ResourceSet; | 103 typedef std::set<PP_Resource> ResourceSet; |
101 | 104 |
102 // Indexed by the var ID. | 105 // Indexed by the var ID. |
103 typedef std::set<int32> VarSet; | 106 typedef std::set<int32> VarSet; |
104 | 107 |
105 // Per-instance data we track. | 108 // Per-instance data we track. |
106 struct InstanceData; | 109 struct InstanceData; |
107 | 110 |
108 // Prohibit creation other then by the Singleton class. | 111 // Prohibit creation other then by the Singleton class. |
109 ResourceTracker(); | 112 ResourceTracker(); |
110 ~ResourceTracker(); | 113 ~ResourceTracker(); |
111 | 114 |
112 // Adds the given resource to the tracker and assigns it a resource ID and | 115 // Adds the given resource to the tracker and assigns it a resource ID and |
113 // refcount of 1. The assigned resource ID will be returned. Used only by the | 116 // refcount of 1. The assigned resource ID will be returned. Used only by the |
114 // Resource class. | 117 // Resource class. |
115 PP_Resource AddResource(Resource* resource); | 118 PP_Resource AddResource(Resource* resource); |
116 | 119 |
117 // The same as AddResource but for Var, and returns the new Var ID. | 120 // The same as AddResource but for Var, and returns the new Var ID. |
118 int32 AddVar(Var* var); | 121 int32 AddVar(Var* var); |
119 | 122 |
| 123 // Force frees all vars and resources associated with the given instance. |
| 124 // If delete_instance is true, the instance tracking information will also |
| 125 // be deleted. |
| 126 void CleanupInstanceData(PP_Instance instance, bool delete_instance); |
| 127 |
120 // Overrides the singleton object. This is used for tests which want to | 128 // Overrides the singleton object. This is used for tests which want to |
121 // specify their own tracker (otherwise, you can get cross-talk between | 129 // specify their own tracker (otherwise, you can get cross-talk between |
122 // tests since the data will live into the subsequent tests). | 130 // tests since the data will live into the subsequent tests). |
123 static void SetSingletonOverride(ResourceTracker* tracker); | 131 static void SetSingletonOverride(ResourceTracker* tracker); |
124 static void ClearSingletonOverride(); | 132 static void ClearSingletonOverride(); |
125 | 133 |
126 // See SetSingletonOverride above. | 134 // See SetSingletonOverride above. |
127 static ResourceTracker* singleton_override_; | 135 static ResourceTracker* singleton_override_; |
128 | 136 |
129 // Last assigned resource & var ID. | 137 // Last assigned resource & var ID. |
(...skipping 24 matching lines...) Expand all Loading... |
154 typedef std::map<PP_Module, PluginModule*> ModuleMap; | 162 typedef std::map<PP_Module, PluginModule*> ModuleMap; |
155 ModuleMap module_map_; | 163 ModuleMap module_map_; |
156 | 164 |
157 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 165 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
158 }; | 166 }; |
159 | 167 |
160 } // namespace ppapi | 168 } // namespace ppapi |
161 } // namespace webkit | 169 } // namespace webkit |
162 | 170 |
163 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ | 171 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
OLD | NEW |