| Index: content/renderer/pepper/v8object_var.h
|
| diff --git a/content/renderer/pepper/npobject_var.h b/content/renderer/pepper/v8object_var.h
|
| similarity index 47%
|
| copy from content/renderer/pepper/npobject_var.h
|
| copy to content/renderer/pepper/v8object_var.h
|
| index 68f90970893bad96d7fd80670bc6d22496a7e7f0..cf3c20f7481f5a5b1f3dab040c63c76467a90e20 100644
|
| --- a/content/renderer/pepper/npobject_var.h
|
| +++ b/content/renderer/pepper/v8object_var.h
|
| @@ -2,70 +2,61 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_
|
| -#define CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_
|
| +#ifndef CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
|
| +#define CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
|
|
|
| #include <string>
|
|
|
| #include "base/compiler_specific.h"
|
| +#include "content/common/content_export.h"
|
| #include "ppapi/c/pp_instance.h"
|
| #include "ppapi/shared_impl/var.h"
|
| -#include "content/common/content_export.h"
|
| -
|
| -typedef struct NPObject NPObject;
|
| -typedef struct _NPVariant NPVariant;
|
| -typedef void* NPIdentifier;
|
| +#include "v8/include/v8.h"
|
|
|
| namespace ppapi {
|
|
|
| -// NPObjectVar -----------------------------------------------------------------
|
| +// V8ObjectVar -----------------------------------------------------------------
|
|
|
| // Represents a JavaScript object Var. By itself, this represents random
|
| -// NPObjects that a given plugin (identified by the resource's module) wants to
|
| +// v8 objects that a given plugin (identified by the resource's module) wants to
|
| // reference. If two different modules reference the same NPObject (like the
|
| -// "window" object), then there will be different NPObjectVar's (and hence
|
| +// "window" object), then there will be different V8ObjectVar's (and hence
|
| // PP_Var IDs) for each module. This allows us to track all references owned by
|
| // a given module and free them when the plugin exits independently of other
|
| // plugins that may be running at the same time.
|
| -class NPObjectVar : public Var {
|
| +class V8ObjectVar : public Var {
|
| public:
|
| - // You should always use FromNPObject to create an NPObjectVar. This function
|
| - // guarantees that we maintain the 1:1 mapping between NPObject and
|
| - // NPObjectVar.
|
| - NPObjectVar(PP_Instance instance, NPObject* np_object);
|
| + V8ObjectVar(PP_Instance instance, v8::Handle<v8::Object> v8_object);
|
|
|
| // Var overrides.
|
| - virtual NPObjectVar* AsNPObjectVar() OVERRIDE;
|
| + virtual V8ObjectVar* AsV8ObjectVar() OVERRIDE;
|
| virtual PP_VarType GetType() const OVERRIDE;
|
|
|
| - // Returns the underlying NPObject corresponding to this NPObjectVar.
|
| - // Guaranteed non-NULL.
|
| - NPObject* np_object() const { return np_object_; }
|
| + // Returns the underlying v8 object corresponding to this V8ObjectVar. This
|
| + // should only be used on the stack.
|
| + v8::Local<v8::Object> GetHandle() const;
|
|
|
| // Notification that the instance was deleted, the internal reference will be
|
| // zeroed out.
|
| void InstanceDeleted();
|
|
|
| // Possibly 0 if the object has outlived its instance.
|
| - PP_Instance pp_instance() const { return pp_instance_; }
|
| + PP_Instance instance() const { return instance_; }
|
|
|
| // Helper function that converts a PP_Var to an object. This will return NULL
|
| // if the PP_Var is not of object type or the object is invalid.
|
| - CONTENT_EXPORT static scoped_refptr<NPObjectVar> FromPPVar(PP_Var var);
|
| + CONTENT_EXPORT static scoped_refptr<V8ObjectVar> FromPPVar(PP_Var var);
|
|
|
| private:
|
| - virtual ~NPObjectVar();
|
| + virtual ~V8ObjectVar();
|
|
|
| - // Possibly 0 if the object has outlived its instance.
|
| - PP_Instance pp_instance_;
|
| + PP_Instance instance_;
|
|
|
| - // Guaranteed non-NULL, this is the underlying object used by WebKit. We
|
| - // hold a reference to this object.
|
| - NPObject* np_object_;
|
| + v8::Persistent<v8::Object> v8_object_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(NPObjectVar);
|
| + DISALLOW_COPY_AND_ASSIGN(V8ObjectVar);
|
| };
|
|
|
| } // ppapi
|
|
|
| -#endif // CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_
|
| +#endif // CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
|
|
|