Commit a9d77326 authored by raymes's avatar raymes Committed by Commit bot

Remove the unused remnants of NPObject from Pepper

BUG=351636

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

Cr-Commit-Position: refs/heads/master@{#293844}
parent 4898820b
......@@ -101,7 +101,7 @@ TEST_F(HostVarTrackerTest, DeleteObjectVarWithInstance) {
EXPECT_EQ(0, tracker().GetLiveV8ObjectVarsForTest(pp_instance2));
}
// Make sure that using the same NPObject should give the same PP_Var
// Make sure that using the same v8 object should give the same PP_Var
// each time.
TEST_F(HostVarTrackerTest, ReuseVar) {
PepperTryCatchForTest try_catch(instance());
......
This diff is collapsed.
This diff is collapsed.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// 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 "base/logging.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 -----------------------------------------------------------------
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);
}
NPObjectVar::~NPObjectVar() {
if (pp_instance())
content::HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this);
WebBindings::releaseObject(np_object_);
}
NPObjectVar* NPObjectVar::AsNPObjectVar() { return this; }
PP_VarType NPObjectVar::GetType() const { return PP_VARTYPE_OBJECT; }
void NPObjectVar::InstanceDeleted() {
DCHECK(pp_instance_);
content::HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this);
pp_instance_ = 0;
}
// static
scoped_refptr<NPObjectVar> NPObjectVar::FromPPVar(PP_Var var) {
if (var.type != PP_VARTYPE_OBJECT)
return scoped_refptr<NPObjectVar>(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());
}
} // namespace ppapi
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// 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_
#include <string>
#include "base/compiler_specific.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;
namespace ppapi {
// NPObjectVar -----------------------------------------------------------------
// Represents a JavaScript object Var. By itself, this represents random
// NPObjects 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
// 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 {
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);
// Var overrides.
virtual NPObjectVar* AsNPObjectVar() 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_; }
// 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_; }
// 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);
private:
virtual ~NPObjectVar();
// Possibly 0 if the object has outlived its instance.
PP_Instance pp_instance_;
// Guaranteed non-NULL, this is the underlying object used by WebKit. We
// hold a reference to this object.
NPObject* np_object_;
DISALLOW_COPY_AND_ASSIGN(NPObjectVar);
};
} // ppapi
#endif // CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_
......@@ -23,7 +23,7 @@ namespace ppapi {
// Represents a JavaScript object Var. By itself, this represents random
// 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
// reference. If two different modules reference the same v8 object (like the
// "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
......
......@@ -80,8 +80,6 @@ StringVar* Var::AsStringVar() { return NULL; }
ArrayBufferVar* Var::AsArrayBufferVar() { return NULL; }
NPObjectVar* Var::AsNPObjectVar() { return NULL; }
V8ObjectVar* Var::AsV8ObjectVar() { return NULL; }
ProxyObjectVar* Var::AsProxyObjectVar() { return NULL; }
......
......@@ -19,7 +19,6 @@ namespace ppapi {
class ArrayBufferVar;
class ArrayVar;
class DictionaryVar;
class NPObjectVar;
class ProxyObjectVar;
class ResourceVar;
class StringVar;
......@@ -36,7 +35,6 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> {
virtual StringVar* AsStringVar();
virtual ArrayBufferVar* AsArrayBufferVar();
virtual NPObjectVar* AsNPObjectVar();
virtual V8ObjectVar* AsV8ObjectVar();
virtual ProxyObjectVar* AsProxyObjectVar();
virtual ArrayVar* AsArrayVar();
......
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