This source file includes following definitions.
- dispatcher_
- SendCallerOwned
- BeginReceiveCallerOwned
- EndReceiveCallerOwned
- ReceivePassRef
- BeginSendPassRef
- EndSendPassRef
- ReleaseObjectRef
#include "ppapi/proxy/plugin_var_serialization_rules.h"
#include "base/logging.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/plugin_var_tracker.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
namespace proxy {
PluginVarSerializationRules::PluginVarSerializationRules(
const base::WeakPtr<PluginDispatcher>& dispatcher)
: var_tracker_(PluginGlobals::Get()->plugin_var_tracker()),
dispatcher_(dispatcher) {
}
PluginVarSerializationRules::~PluginVarSerializationRules() {
}
PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT)
return var_tracker_->GetHostObject(var);
return var;
}
PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT) {
return dispatcher_.get() ? var_tracker_->TrackObjectWithNoReference(
var, dispatcher_.get())
: PP_MakeUndefined();
}
return var;
}
void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT) {
var_tracker_->StopTrackingObjectWithNoReference(var);
} else if (var.type >= PP_VARTYPE_STRING) {
var_tracker_->ReleaseVar(var);
}
}
PP_Var PluginVarSerializationRules::ReceivePassRef(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT) {
return dispatcher_.get()
? var_tracker_->ReceiveObjectPassRef(var, dispatcher_.get())
: PP_MakeUndefined();
}
return var;
}
PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT)
return var_tracker_->GetHostObject(var);
return var;
}
void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var) {
if (var.type == PP_VARTYPE_OBJECT) {
if (dispatcher_.get())
var_tracker_->ReleaseHostObject(dispatcher_.get(), var);
} else if (var.type >= PP_VARTYPE_STRING) {
var_tracker_->ReleaseVar(var);
}
}
void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) {
var_tracker_->ReleaseVar(var);
}
}
}