This source file includes following definitions.
- HandleMessage
- ppp_messaging_impl_
- GetProxyInterface
- OnMessageReceived
- OnMsgHandleMessage
#include "ppapi/proxy/ppp_messaging_proxy.h"
#include <algorithm>
#include "ppapi/c/ppp_messaging.h"
#include "ppapi/proxy/host_dispatcher.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/plugin_var_tracker.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/var_tracker.h"
namespace ppapi {
namespace proxy {
namespace {
#if !defined(OS_NACL)
void HandleMessage(PP_Instance instance, PP_Var message_data) {
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher || (message_data.type == PP_VARTYPE_OBJECT)) {
NOTREACHED();
return;
}
dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage(
API_ID_PPP_MESSAGING,
instance,
SerializedVarSendInputShmem(dispatcher, message_data, instance)));
}
static const PPP_Messaging messaging_interface = {
&HandleMessage
};
#else
static const PPP_Messaging messaging_interface = {};
#endif
}
PPP_Messaging_Proxy::PPP_Messaging_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher),
ppp_messaging_impl_(NULL) {
if (dispatcher->IsPlugin()) {
ppp_messaging_impl_ = static_cast<const PPP_Messaging*>(
dispatcher->local_get_interface()(PPP_MESSAGING_INTERFACE));
}
}
PPP_Messaging_Proxy::~PPP_Messaging_Proxy() {
}
const PPP_Messaging* PPP_Messaging_Proxy::GetProxyInterface() {
return &messaging_interface;
}
bool PPP_Messaging_Proxy::OnMessageReceived(const IPC::Message& msg) {
if (!dispatcher()->IsPlugin())
return false;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPP_Messaging_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPMessaging_HandleMessage,
OnMsgHandleMessage)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void PPP_Messaging_Proxy::OnMsgHandleMessage(
PP_Instance instance, SerializedVarReceiveInput message_data) {
PP_Var received_var(message_data.GetForInstance(dispatcher(), instance));
PpapiGlobals::Get()->GetVarTracker()->AddRefVar(received_var);
CallWhileUnlocked(ppp_messaging_impl_->HandleMessage,
instance,
received_var);
}
}
}