Index: content/renderer/pepper/host_var_tracker.h |
diff --git a/content/renderer/pepper/host_var_tracker.h b/content/renderer/pepper/host_var_tracker.h |
index 6abbf869765c06a6c180d3a0181a82807369eab4..e412bedb2cb52cbea2884513a937a3fd6fee3c93 100644 |
--- a/content/renderer/pepper/host_var_tracker.h |
+++ b/content/renderer/pepper/host_var_tracker.h |
@@ -18,40 +18,34 @@ |
#include "ppapi/shared_impl/host_resource.h" |
#include "ppapi/shared_impl/resource_tracker.h" |
#include "ppapi/shared_impl/var_tracker.h" |
- |
-typedef struct NPObject NPObject; |
+#include "v8/include/v8.h" |
namespace ppapi { |
class ArrayBufferVar; |
-class NPObjectVar; |
+class V8ObjectVar; |
class Var; |
} |
namespace content { |
-// Adds NPObject var tracking to the standard PPAPI VarTracker for use in the |
-// renderer. |
class HostVarTracker : public ppapi::VarTracker { |
public: |
HostVarTracker(); |
virtual ~HostVarTracker(); |
- // Tracks all live NPObjectVar. This is so we can map between instance + |
- // NPObject and get the NPObjectVar corresponding to it. This Add/Remove |
- // function is called by the NPObjectVar when it is created and |
- // destroyed. |
- void AddNPObjectVar(ppapi::NPObjectVar* object_var); |
- void RemoveNPObjectVar(ppapi::NPObjectVar* object_var); |
+ // Tracks all live V8ObjectVar. This is so we can map between instance + |
+ // V8Object and get the V8ObjectVar corresponding to it. This Add/Remove |
+ // function is called by the V8ObjectVar when it is created and destroyed. |
+ void AddV8ObjectVar(ppapi::V8ObjectVar* object_var); |
+ void RemoveV8ObjectVar(ppapi::V8ObjectVar* object_var); |
- // Looks up a previously registered NPObjectVar for the given NPObject and |
- // instance. Returns NULL if there is no NPObjectVar corresponding to the |
- // given NPObject for the given instance. See AddNPObjectVar above. |
- ppapi::NPObjectVar* NPObjectVarForNPObject(PP_Instance instance, |
- NPObject* np_object); |
+ // Creates or retrieves a V8ObjectVar. |
+ PP_Var V8ObjectVarForV8Object(PP_Instance instance, |
+ v8::Handle<v8::Object> object); |
- // Returns the number of NPObjectVar's associated with the given instance. |
+ // Returns the number of AddV8ObjectVar's associated with the given instance. |
// Returns 0 if the instance isn't known. |
- CONTENT_EXPORT int GetLiveNPObjectVarsForInstance(PP_Instance instance) const; |
+ CONTENT_EXPORT int GetLiveV8ObjectVarsForInstance(PP_Instance instance) const; |
// VarTracker public implementation. |
virtual PP_Var MakeResourcePPVarFromMessage( |
@@ -80,20 +74,24 @@ class HostVarTracker : public ppapi::VarTracker { |
// Clear the reference count of the given object and remove it from |
// live_vars_. |
- void ForceReleaseNPObject(ppapi::NPObjectVar* object_var); |
- |
- typedef std::map<NPObject*, ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; |
- |
- // Lists all known NPObjects, first indexed by the corresponding instance, |
- // then by the NPObject*. This allows us to look up an NPObjectVar given |
- // these two pieces of information. |
- // |
- // The instance map is lazily managed, so we'll add the |
- // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, |
- // and delete it when it's empty. |
- typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > |
- InstanceMap; |
- InstanceMap instance_map_; |
+ void ForceReleaseV8Object(ppapi::V8ObjectVar* object_var); |
+ |
+ struct V8ObjectVarKey { |
+ explicit V8ObjectVarKey(ppapi::V8ObjectVar* object_var); |
+ V8ObjectVarKey(PP_Instance i, v8::Handle<v8::Object> object); |
+ ~V8ObjectVarKey(); |
+ |
+ bool operator<(const V8ObjectVarKey& other) const; |
+ bool operator==(const V8ObjectVarKey& other) const; |
+ |
+ PP_Instance instance; |
+ int hash; |
+ }; |
+ typedef std::multimap<V8ObjectVarKey, ppapi::V8ObjectVar*> ObjectMap; |
+ ObjectMap::const_iterator GetForV8Object(PP_Instance instance, |
+ v8::Handle<v8::Object> object) const; |
+ |
+ ObjectMap object_map_; |
// Tracks all shared memory handles used for transmitting array buffers. |
struct SharedMemoryMapEntry { |