Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 } | 733 } |
| 734 #endif | 734 #endif |
| 735 | 735 |
| 736 process_->Send(new NaClProcessMsg_Start(params)); | 736 process_->Send(new NaClProcessMsg_Start(params)); |
| 737 | 737 |
| 738 internal_->sockets_for_sel_ldr.clear(); | 738 internal_->sockets_for_sel_ldr.clear(); |
| 739 return true; | 739 return true; |
| 740 } | 740 } |
| 741 | 741 |
| 742 bool NaClProcessHost::SendStart() { | 742 bool NaClProcessHost::SendStart() { |
| 743 if (!enable_ipc_proxy_) { | 743 // If render_view_id == 0, reply to the Renderer now, and skip creation |
| 744 // of the PPAPI IPC proxy channel in OnPpapiChannelCreated. | |
| 745 if (!enable_ipc_proxy_ || !render_view_id_) { | |
|
bbudge
2012/11/30 00:49:46
If you really don't need any IPC stuff, it would b
jvoung (off chromium)
2012/11/30 01:34:09
Ah ok. Done.
| |
| 744 if (!ReplyToRenderer(IPC::ChannelHandle())) | 746 if (!ReplyToRenderer(IPC::ChannelHandle())) |
| 745 return false; | 747 return false; |
| 746 } | 748 } |
| 747 return StartNaClExecution(); | 749 return StartNaClExecution(); |
| 748 } | 750 } |
| 749 | 751 |
| 750 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 752 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 751 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin | 753 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin |
| 752 // listener. | 754 // listener. |
| 753 void NaClProcessHost::OnPpapiChannelCreated( | 755 void NaClProcessHost::OnPpapiChannelCreated( |
| 754 const IPC::ChannelHandle& channel_handle) { | 756 const IPC::ChannelHandle& channel_handle) { |
| 755 DCHECK(enable_ipc_proxy_); | 757 DCHECK(enable_ipc_proxy_); |
| 756 // If the proxy channel is null, this must be the initial NaCl-Browser IPC | 758 // If the proxy channel is null, this must be the initial NaCl-Browser IPC |
| 757 // channel. | 759 // channel. |
| 758 if (!ipc_proxy_channel_.get()) { | 760 if (!ipc_proxy_channel_.get()) { |
| 759 ipc_proxy_channel_.reset( | 761 // If render_view_id_ == 0, then we are launching a nexe that does not need |
| 760 new IPC::ChannelProxy(channel_handle, | 762 // the PPAPI IPC proxy. In that case, we have already ReplyToRenderer'ed |
| 761 IPC::Channel::MODE_CLIENT, | 763 // in SendStart, so there is nothing to do. |
| 762 &ipc_plugin_listener_, | 764 // Otherwise, we need the ipc_proxy_channel_. |
| 763 base::MessageLoopProxy::current())); | 765 if (render_view_id_) { |
| 764 // Create the browser ppapi host and enable PPAPI message dispatching to the | 766 ipc_proxy_channel_.reset( |
| 765 // browser process. | 767 new IPC::ChannelProxy(channel_handle, |
| 766 content::BrowserPpapiHost::CreateExternalPluginProcess( | 768 IPC::Channel::MODE_CLIENT, |
| 767 process_.get(), // sender | 769 &ipc_plugin_listener_, |
| 768 permissions_, | 770 base::MessageLoopProxy::current())); |
| 769 process_->GetData().handle, | 771 // Create the browser ppapi host and enable PPAPI message dispatching |
| 770 ipc_proxy_channel_.get(), | 772 // to the browser process. |
| 771 chrome_render_message_filter_->GetHostResolver(), | 773 content::BrowserPpapiHost::CreateExternalPluginProcess( |
| 772 chrome_render_message_filter_->render_process_id(), | 774 process_.get(), // sender |
| 773 render_view_id_); | 775 permissions_, |
| 774 // Send a message to create the NaCl-Renderer channel. The handle is just | 776 process_->GetData().handle, |
| 775 // a place holder. | 777 ipc_proxy_channel_.get(), |
| 776 ipc_proxy_channel_->Send( | 778 chrome_render_message_filter_->GetHostResolver(), |
| 777 new PpapiMsg_CreateNaClChannel( | 779 chrome_render_message_filter_->render_process_id(), |
| 778 chrome_render_message_filter_->render_process_id(), | 780 render_view_id_); |
| 779 permissions_, | 781 // Send a message to create the NaCl-Renderer channel. The handle is just |
| 780 chrome_render_message_filter_->off_the_record(), | 782 // a place holder. |
| 781 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, | 783 ipc_proxy_channel_->Send( |
| 782 IPC::InvalidPlatformFileForTransit()))); | 784 new PpapiMsg_CreateNaClChannel( |
| 785 chrome_render_message_filter_->render_process_id(), | |
| 786 permissions_, | |
| 787 chrome_render_message_filter_->off_the_record(), | |
| 788 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, | |
| 789 IPC::InvalidPlatformFileForTransit()))); | |
| 790 } | |
| 783 } else if (reply_msg_) { | 791 } else if (reply_msg_) { |
| 784 // Otherwise, this must be a renderer channel. | 792 // Otherwise, this must be a renderer channel. |
| 785 ReplyToRenderer(channel_handle); | 793 ReplyToRenderer(channel_handle); |
| 786 } else { | 794 } else { |
| 787 // Attempt to open more than 1 renderer channel is not supported. | 795 // Attempt to open more than 1 renderer channel is not supported. |
| 788 // Shut down the NaCl process. | 796 // Shut down the NaCl process. |
| 789 process_->GetHost()->ForceShutdown(); | 797 process_->GetHost()->ForceShutdown(); |
| 790 } | 798 } |
| 791 } | 799 } |
| 792 | 800 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 } else { | 907 } else { |
| 900 NaClStartDebugExceptionHandlerThread( | 908 NaClStartDebugExceptionHandlerThread( |
| 901 process_handle.Take(), info, | 909 process_handle.Take(), info, |
| 902 base::MessageLoopProxy::current(), | 910 base::MessageLoopProxy::current(), |
| 903 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 911 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 904 weak_factory_.GetWeakPtr())); | 912 weak_factory_.GetWeakPtr())); |
| 905 return true; | 913 return true; |
| 906 } | 914 } |
| 907 } | 915 } |
| 908 #endif | 916 #endif |
| OLD | NEW |