summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_resource_tracker.h
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/plugins/pepper_resource_tracker.h')
-rw-r--r--webkit/glue/plugins/pepper_resource_tracker.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/webkit/glue/plugins/pepper_resource_tracker.h b/webkit/glue/plugins/pepper_resource_tracker.h
index 59f02d2..5c27ebd 100644
--- a/webkit/glue/plugins/pepper_resource_tracker.h
+++ b/webkit/glue/plugins/pepper_resource_tracker.h
@@ -5,18 +5,22 @@
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
+#include <map>
#include <utility>
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/ref_counted.h"
#include "base/singleton.h"
+#include "third_party/ppapi/c/pp_instance.h"
+#include "third_party/ppapi/c/pp_module.h"
#include "third_party/ppapi/c/pp_resource.h"
typedef struct NPObject NPObject;
namespace pepper {
+class PluginInstance;
class PluginModule;
class Resource;
@@ -31,6 +35,8 @@ class ResourceTracker {
return Singleton<ResourceTracker>::get();
}
+ // PP_Resources --------------------------------------------------------------
+
// The returned pointer will be NULL if there is no resource. Note that this
// return value is a scoped_refptr so that we ensure the resource is valid
// from the point of the lookup to the point that the calling code needs it.
@@ -48,6 +54,34 @@ class ResourceTracker {
// This is slow, use only for testing.
uint32 GetLiveObjectsForModule(PluginModule* module) const;
+ // PP_Modules ----------------------------------------------------------------
+
+ // Adds a new plugin module to the list of tracked module, and returns a new
+ // module handle to identify it.
+ PP_Module AddModule(PluginModule* module);
+
+ // Called when a plugin modulde was deleted and should no longer be tracked.
+ // The given handle should be one generated by AddModule.
+ void ModuleDeleted(PP_Module module);
+
+ // Returns a pointer to the plugin modulde object associated with the given
+ // modulde handle. The return value will be NULL if the handle is invalid.
+ PluginModule* GetModule(PP_Module module);
+
+ // PP_Instances --------------------------------------------------------------
+
+ // Adds a new plugin instance to the list of tracked instances, and returns a
+ // new instance handle to identify it.
+ PP_Instance AddInstance(PluginInstance* instance);
+
+ // Called when a plugin instance was deleted and should no longer be tracked.
+ // The given handle should be one generated by AddInstance.
+ void InstanceDeleted(PP_Instance instance);
+
+ // Returns a pointer to the plugin instance object associated with the given
+ // instance handle. The return value will be NULL if the handle is invalid.
+ PluginInstance* GetInstance(PP_Instance instance);
+
private:
friend struct DefaultSingletonTraits<ResourceTracker>;
friend class Resource;
@@ -74,6 +108,16 @@ class ResourceTracker {
typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap;
ResourceMap live_resources_;
+ // Tracks all live instances. The pointers are non-owning, the PluginInstance
+ // destructor will notify us when the instance is deleted.
+ typedef std::map<PP_Instance, PluginInstance*> InstanceMap;
+ InstanceMap instance_map_;
+
+ // Tracks all live modules. The pointers are non-owning, the PluginModule
+ // destructor will notify us when the module is deleted.
+ typedef std::map<PP_Module, PluginModule*> ModuleMap;
+ ModuleMap module_map_;
+
DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
};