| Index: content/renderer/pepper/v8object_var.cc
|
| diff --git a/content/renderer/pepper/npobject_var.cc b/content/renderer/pepper/v8object_var.cc
|
| similarity index 27%
|
| copy from content/renderer/pepper/npobject_var.cc
|
| copy to content/renderer/pepper/v8object_var.cc
|
| index 50ccf87b4df24cb12429e5a4733a095b53504408..9c33e2240f7784d1876cded3d4ae4e173e250c8c 100644
|
| --- a/content/renderer/pepper/npobject_var.cc
|
| +++ b/content/renderer/pepper/v8object_var.cc
|
| @@ -2,51 +2,63 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/renderer/pepper/npobject_var.h"
|
| +#include "content/renderer/pepper/v8object_var.h"
|
|
|
| #include "base/logging.h"
|
| +#include "content/public/renderer/pepper_plugin_instance.h"
|
| #include "content/renderer/pepper/host_globals.h"
|
| -#include "content/renderer/pepper/host_var_tracker.h"
|
| #include "ppapi/c/pp_var.h"
|
| -#include "third_party/WebKit/public/web/WebBindings.h"
|
| -
|
| -using blink::WebBindings;
|
|
|
| namespace ppapi {
|
|
|
| -// NPObjectVar -----------------------------------------------------------------
|
| +// V8ObjectVar -----------------------------------------------------------------
|
|
|
| -NPObjectVar::NPObjectVar(PP_Instance instance, NPObject* np_object)
|
| - : pp_instance_(instance), np_object_(np_object) {
|
| - WebBindings::retainObject(np_object_);
|
| - content::HostGlobals::Get()->host_var_tracker()->AddNPObjectVar(this);
|
| +V8ObjectVar::V8ObjectVar(PP_Instance instance,
|
| + v8::Handle<v8::Object> v8_object)
|
| + : instance_(instance) {
|
| + v8_object_.Reset(
|
| + content::PepperPluginInstance::Get(instance_)->GetIsolate(), v8_object);
|
| + content::HostGlobals::Get()->host_var_tracker()->AddV8ObjectVar(this);
|
| }
|
|
|
| -NPObjectVar::~NPObjectVar() {
|
| - if (pp_instance())
|
| - content::HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this);
|
| - WebBindings::releaseObject(np_object_);
|
| +V8ObjectVar::~V8ObjectVar() {
|
| + if (instance_)
|
| + content::HostGlobals::Get()->host_var_tracker()->RemoveV8ObjectVar(this);
|
| + v8_object_.Reset();
|
| }
|
|
|
| -NPObjectVar* NPObjectVar::AsNPObjectVar() { return this; }
|
| +V8ObjectVar* V8ObjectVar::AsV8ObjectVar() {
|
| + return this;
|
| +}
|
|
|
| -PP_VarType NPObjectVar::GetType() const { return PP_VARTYPE_OBJECT; }
|
| +PP_VarType V8ObjectVar::GetType() const {
|
| + return PP_VARTYPE_OBJECT;
|
| +}
|
| +
|
| +v8::Local<v8::Object> V8ObjectVar::GetHandle() const {
|
| + content::PepperPluginInstance* instance =
|
| + content::PepperPluginInstance::Get(instance_);
|
| + if (instance)
|
| + return v8::Local<v8::Object>::New(instance->GetIsolate(), v8_object_);
|
| + return v8::Local<v8::Object>();
|
| +}
|
|
|
| -void NPObjectVar::InstanceDeleted() {
|
| - DCHECK(pp_instance_);
|
| - content::HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this);
|
| - pp_instance_ = 0;
|
| +void V8ObjectVar::InstanceDeleted() {
|
| + // This is called by the HostVarTracker which will take care of removing us
|
| + // from its set.
|
| + DCHECK(instance_);
|
| + instance_ = 0;
|
| }
|
|
|
| // static
|
| -scoped_refptr<NPObjectVar> NPObjectVar::FromPPVar(PP_Var var) {
|
| +scoped_refptr<V8ObjectVar> V8ObjectVar::FromPPVar(PP_Var var) {
|
| if (var.type != PP_VARTYPE_OBJECT)
|
| - return scoped_refptr<NPObjectVar>(NULL);
|
| + return scoped_refptr<V8ObjectVar>(NULL);
|
| scoped_refptr<Var> var_object(
|
| PpapiGlobals::Get()->GetVarTracker()->GetVar(var));
|
| if (!var_object.get())
|
| - return scoped_refptr<NPObjectVar>();
|
| - return scoped_refptr<NPObjectVar>(var_object->AsNPObjectVar());
|
| + return scoped_refptr<V8ObjectVar>();
|
| + return scoped_refptr<V8ObjectVar>(var_object->AsV8ObjectVar());
|
| }
|
|
|
| } // namespace ppapi
|
|
|