This source file includes following definitions.
- InitBrokerWithChannel
- OnMessageReceived
- OnMsgConnectToPlugin
- OnChannelError
- OnChannelError
#include "ppapi/proxy/broker_dispatcher.h"
#include "base/sync_socket.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/platform_file.h"
namespace ppapi {
namespace proxy {
BrokerDispatcher::BrokerDispatcher(PP_ConnectInstance_Func connect_instance)
: connect_instance_(connect_instance) {
}
BrokerDispatcher::~BrokerDispatcher() {
}
bool BrokerDispatcher::InitBrokerWithChannel(
ProxyChannel::Delegate* delegate,
base::ProcessId peer_pid,
const IPC::ChannelHandle& channel_handle,
bool is_client) {
return ProxyChannel::InitWithChannel(delegate, peer_pid, channel_handle,
is_client);
}
bool BrokerDispatcher::OnMessageReceived(const IPC::Message& msg) {
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BrokerDispatcher, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_ConnectToPlugin, OnMsgConnectToPlugin)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
return false;
}
void BrokerDispatcher::OnMsgConnectToPlugin(
PP_Instance instance,
IPC::PlatformFileForTransit handle,
int32_t* result) {
if (handle == IPC::InvalidPlatformFileForTransit()) {
*result = PP_ERROR_FAILED;
} else {
base::SyncSocket::Handle socket_handle =
IPC::PlatformFileForTransitToPlatformFile(handle);
if (connect_instance_) {
*result = connect_instance_(instance,
ppapi::PlatformFileToInt(socket_handle));
} else {
*result = PP_ERROR_FAILED;
base::SyncSocket temp_socket(socket_handle);
}
}
}
BrokerHostDispatcher::BrokerHostDispatcher()
: BrokerDispatcher(NULL) {
}
void BrokerHostDispatcher::OnChannelError() {
DVLOG(1) << "BrokerHostDispatcher::OnChannelError()";
BrokerDispatcher::OnChannelError();
}
BrokerSideDispatcher::BrokerSideDispatcher(
PP_ConnectInstance_Func connect_instance)
: BrokerDispatcher(connect_instance) {
}
void BrokerSideDispatcher::OnChannelError() {
DVLOG(1) << "BrokerSideDispatcher::OnChannelError()";
BrokerDispatcher::OnChannelError();
delete this;
}
}
}