Commit 7f1e19ef authored by raymes@chromium.org's avatar raymes@chromium.org

Change V8ObjectVar to store a pointer to the instance rather than an ID

This changes the currently unused V8ObjectVar to store a pointer to the
instance rather than a PP_Instance ID. This is just more convenient for
the code which uses the V8ObjectVar. When the instance is deleted, the
pointer will be cleared so it should always be valid or NULL.

BUG=351636

Review URL: https://codereview.chromium.org/464653003

Cr-Commit-Position: refs/heads/master@{#289191}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289191 0039d316-1c4b-4281-b951-d872f2087c98
parent 887a7eb8
......@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "content/public/renderer/pepper_plugin_instance.h"
#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "ppapi/c/pp_var.h"
namespace ppapi {
......@@ -15,9 +16,8 @@ namespace ppapi {
V8ObjectVar::V8ObjectVar(PP_Instance instance,
v8::Handle<v8::Object> v8_object)
: instance_(instance) {
v8_object_.Reset(
content::PepperPluginInstance::Get(instance_)->GetIsolate(), v8_object);
: instance_(content::HostGlobals::Get()->GetInstance(instance)) {
v8_object_.Reset(instance_->GetIsolate(), v8_object);
content::HostGlobals::Get()->host_var_tracker()->AddV8ObjectVar(this);
}
......@@ -36,10 +36,8 @@ PP_VarType V8ObjectVar::GetType() const {
}
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_);
if (instance_)
return v8::Local<v8::Object>::New(instance_->GetIsolate(), v8_object_);
return v8::Local<v8::Object>();
}
......@@ -47,7 +45,7 @@ void V8ObjectVar::InstanceDeleted() {
// This is called by the HostVarTracker which will take care of removing us
// from its set.
DCHECK(instance_);
instance_ = 0;
instance_ = NULL;
}
// static
......
......@@ -13,6 +13,10 @@
#include "ppapi/shared_impl/var.h"
#include "v8/include/v8.h"
namespace content {
class PepperPluginInstanceImpl;
} // namespace content
namespace ppapi {
// V8ObjectVar -----------------------------------------------------------------
......@@ -40,8 +44,8 @@ class V8ObjectVar : public Var {
// zeroed out.
void InstanceDeleted();
// Possibly 0 if the object has outlived its instance.
PP_Instance instance() const { return instance_; }
// Possibly NULL if the object has outlived its instance.
content::PepperPluginInstanceImpl* 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.
......@@ -50,7 +54,7 @@ class V8ObjectVar : public Var {
private:
virtual ~V8ObjectVar();
PP_Instance instance_;
content::PepperPluginInstanceImpl* instance_;
v8::Persistent<v8::Object> v8_object_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment