Commit a3719b61 authored by brettw@chromium.org's avatar brettw@chromium.org

Add the PP_Instance to resource object base.

This will allow us to get the instance for a resource consistently in the
proxy and webkit glue.

Review URL: http://codereview.chromium.org/7461147

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96473 0039d316-1c4b-4281-b951-d872f2087c98
parent 3aada460
......@@ -8,7 +8,8 @@ namespace pp {
namespace proxy {
PluginResource::PluginResource(const HostResource& resource)
: host_resource_(resource) {
: ResourceObjectBase(resource.instance()),
host_resource_(resource) {
}
PluginResource::~PluginResource() {
......
......@@ -4,8 +4,16 @@
#include "ppapi/shared_impl/resource_object_base.h"
#include "base/logging.h"
namespace ppapi {
ResourceObjectBase::ResourceObjectBase(PP_Instance instance)
: pp_instance_(instance) {
// Instance should be valid (nonzero).
DCHECK(instance);
}
ResourceObjectBase::~ResourceObjectBase() {
}
......
......@@ -8,6 +8,7 @@
#include <stddef.h> // For NULL.
#include "base/memory/ref_counted.h"
#include "ppapi/c/pp_instance.h"
#define FOR_ALL_PPAPI_RESOURCE_APIS(F) \
F(PPB_AudioConfig_API) \
......@@ -55,8 +56,11 @@ FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS)
class ResourceObjectBase : public base::RefCounted<ResourceObjectBase> {
public:
ResourceObjectBase(PP_Instance instance);
virtual ~ResourceObjectBase();
PP_Instance pp_instance() const { return pp_instance_; }
// Dynamic casting for this object. Returns the pointer to the given type if
// Inheritance-based dynamic casting for this object. Returns the pointer to
// the given type if it's supported. Derived classes override the functions
......@@ -68,6 +72,11 @@ class ResourceObjectBase : public base::RefCounted<ResourceObjectBase> {
// Template-based dynamic casting. See specializations below.
template <typename T> T* GetAs() { return NULL; }
private:
PP_Instance pp_instance_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceObjectBase);
};
// Template-based dynamic casting. These specializations forward to the
......
......@@ -14,7 +14,9 @@ namespace webkit {
namespace ppapi {
Resource::Resource(PluginInstance* instance)
: resource_id_(0), instance_(instance) {
: ResourceObjectBase(instance->pp_instance()),
resource_id_(0),
instance_(instance) {
ResourceTracker::Get()->ResourceCreated(this, instance_);
}
......
......@@ -45,7 +45,14 @@ namespace ppapi {
class URLRequestInfoTest : public PpapiUnittest {
public:
URLRequestInfoTest() : info_(new PPB_URLRequestInfo_Impl(instance())) {
URLRequestInfoTest() {
}
virtual void SetUp() OVERRIDE {
PpapiUnittest::SetUp();
// Must do this after the normal SetUp so the instance is valid.
info_ = new PPB_URLRequestInfo_Impl(instance());
}
static void SetUpTestCase() {
......
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