This source file includes following definitions.
- GetReference
- NotifyLastPluginRefWasDeleted
- NotifyInstanceWasDeleted
- OnReplyReceived
- Log
- RemoveFromResourceTracker
#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(ResourceObjectType type, PP_Instance instance)
: host_resource_(HostResource::MakeInstanceOnly(instance)) {
DCHECK(instance);
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
if (type == OBJECT_IS_IMPL) {
host_resource_.SetHostResource(instance, pp_resource_);
}
}
Resource::Resource(ResourceObjectType type, const HostResource& host_resource)
: host_resource_(host_resource) {
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
if (type == OBJECT_IS_IMPL) {
DCHECK(host_resource_.host_resource() == 0);
host_resource_.SetHostResource(host_resource.instance(), pp_resource_);
}
}
Resource::Resource(Untracked) {
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
}
Resource::~Resource() { RemoveFromResourceTracker(); }
PP_Resource Resource::GetReference() {
PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource());
return pp_resource();
}
void Resource::NotifyLastPluginRefWasDeleted() {
LastPluginRefWasDeleted();
}
void Resource::NotifyInstanceWasDeleted() {
scoped_refptr<Resource> keep_alive(this);
InstanceWasDeleted();
host_resource_ = HostResource();
}
void Resource::OnReplyReceived(const proxy::ResourceMessageReplyParams& params,
const IPC::Message& msg) {
NOTREACHED();
}
void Resource::Log(PP_LogLevel level, const std::string& message) {
PpapiGlobals::Get()->LogWithSource(
pp_instance(), level, std::string(), message);
}
void Resource::RemoveFromResourceTracker() {
PpapiGlobals::Get()->GetResourceTracker()->RemoveResource(this);
}
#define DEFINE_TYPE_GETTER(RESOURCE) \
thunk::RESOURCE* Resource::As##RESOURCE() { return NULL; }
FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
#undef DEFINE_TYPE_GETTER
}