blob: 4e1f2a8691f696fcabb97c04b5f84da334c8c721 [file] [log] [blame]
// 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 "ppapi/shared_impl/resource.h"
#include "base/logging.h"
#include "ppapi/shared_impl/resource_tracker.h"
#include "ppapi/shared_impl/ppapi_globals.h"
namespace ppapi {
Resource::Resource(PP_Instance instance) {
// The instance should always be valid (nonzero).
// For the in-process case, the host resource and resource are the same.
// AddResource needs our instance() getter to work, and that goes through
// the host resource, so we need to fill that first even though we don't
// have a resource ID yet, then fill the resource in later.
host_resource_ = HostResource::MakeInstanceOnly(instance);
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
host_resource_.SetHostResource(instance, pp_resource_);
Resource::Resource(const HostResource& host_resource)
: host_resource_(host_resource) {
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
Resource::~Resource() {
PP_Resource Resource::GetReference() {
return pp_resource();
void Resource::LastPluginRefWasDeleted() {
void Resource::InstanceWasDeleted() {
host_resource_ = HostResource();
thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; }
} // namespace ppapi