Commit aeee1ee5 authored by teravest@chromium.org's avatar teravest@chromium.org

Pepper: Split PpapiHostMsg_ChannelCreated use.

PpapiHostMsg_ChannelCreated is used for two purposes:
  * Notifying the browser that a browser<->plugin channel has been created, and
  * Notifying that browser that a renderer<->plugin channel has been created.

In this case renderer<->plugin channel is for NaCl-based plugins, and is
special because it does some inspection of message contents and passes on the
message to the untrusted side of the plugin.

I've changed this because I think it makes the code easier to read, and I'm
adding an additional renderer<->plugin channel anyway.

BUG=
TBR=mseaborn,jschuh

Review URL: https://codereview.chromium.org/98183012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243101 0039d316-1c4b-4281-b951-d872f2087c98
parent 9134a8c5
......@@ -572,7 +572,7 @@ bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
OnAttachDebugExceptionHandler)
#endif
IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated,
OnPpapiChannelCreated)
OnPpapiBrowserChannelCreated)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
......@@ -778,14 +778,11 @@ bool NaClProcessHost::SendStart() {
}
// This method is called when NaClProcessHostMsg_PpapiChannelCreated is
// received or PpapiHostMsg_ChannelCreated is forwarded by our plugin
// listener.
void NaClProcessHost::OnPpapiChannelCreated(
// received.
void NaClProcessHost::OnPpapiBrowserChannelCreated(
const IPC::ChannelHandle& channel_handle) {
// Only renderer processes should create a channel.
DCHECK(enable_ppapi_proxy());
// If the proxy channel is null, this must be the initial NaCl-Browser IPC
// channel.
if (!ipc_proxy_channel_.get()) {
DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type);
......@@ -833,11 +830,19 @@ void NaClProcessHost::OnPpapiChannelCreated(
args,
SerializedHandle(SerializedHandle::CHANNEL_HANDLE,
IPC::InvalidPlatformFileForTransit())));
} else if (reply_msg_) {
// Otherwise, this must be a renderer channel.
} else {
// Attempt to open more than 1 browser channel is not supported.
// Shut down the NaCl process.
process_->GetHost()->ForceShutdown();
}
}
void NaClProcessHost::OnPpapiRendererChannelCreated(
const IPC::ChannelHandle& channel_handle) {
if (reply_msg_) {
ReplyToRenderer(channel_handle);
} else {
// Attempt to open more than 1 renderer channel is not supported.
// Attempt to open more than 1 NaCl renderer channel is not supported.
// Shut down the NaCl process.
process_->GetHost()->ForceShutdown();
}
......@@ -848,8 +853,8 @@ bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) {
// These messages come from untrusted code so should be handled with care.
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
OnPpapiChannelCreated)
IPC_MESSAGE_HANDLER(PpapiHostMsg_NaClChannelCreated,
OnPpapiRendererChannelCreated)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
......
......@@ -176,8 +176,11 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
IPC::Message* reply_msg);
#endif
// Called when a PPAPI IPC channel has been created.
void OnPpapiChannelCreated(const IPC::ChannelHandle& channel_handle);
// Called when the PPAPI IPC channel to the browser has been created.
void OnPpapiBrowserChannelCreated(const IPC::ChannelHandle& channel_handle);
// Called when the PPAPI IPC channel to the renderer has been created.
void OnPpapiRendererChannelCreated(const IPC::ChannelHandle& channel_handle);
// Called by PluginListener, so messages from the untrusted side of
// the IPC proxy can be handled.
bool OnUntrustedMessageForwarded(const IPC::Message& msg);
......
......@@ -521,7 +521,7 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
nacl_desc.reset(new NaClDescWrapper(ipc_adapter->MakeNaClDesc()));
// Send back a message that the channel was created.
scoped_ptr<IPC::Message> response(
new PpapiHostMsg_ChannelCreated(channel_handle));
new PpapiHostMsg_NaClChannelCreated(channel_handle));
task_runner_->PostTask(FROM_HERE,
base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this,
base::Passed(&response)));
......
......@@ -737,6 +737,8 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_Keepalive)
// initialize properly.
IPC_MESSAGE_CONTROL1(PpapiHostMsg_ChannelCreated,
IPC::ChannelHandle /* handle */)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_NaClChannelCreated,
IPC::ChannelHandle /* handle */)
// Logs the given message to the console of all instances.
IPC_MESSAGE_CONTROL4(PpapiHostMsg_LogWithSource,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment