| 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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 return StartNaClExecution(); | 775 return StartNaClExecution(); |
| 776 } | 776 } |
| 777 | 777 |
| 778 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 778 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 779 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin | 779 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin |
| 780 // listener. | 780 // listener. |
| 781 void NaClProcessHost::OnPpapiChannelCreated( | 781 void NaClProcessHost::OnPpapiChannelCreated( |
| 782 const IPC::ChannelHandle& channel_handle) { | 782 const IPC::ChannelHandle& channel_handle) { |
| 783 // Only renderer processes should create a channel. | 783 // Only renderer processes should create a channel. |
| 784 DCHECK(enable_ppapi_proxy()); | 784 DCHECK(enable_ppapi_proxy()); |
| 785 // If the proxy channel is null, this must be the initial NaCl-Browser IPC | |
| 786 // channel. | |
| 787 if (!ipc_proxy_channel_.get()) { | 785 if (!ipc_proxy_channel_.get()) { |
| 788 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type); | 786 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type); |
| 789 | 787 |
| 790 ipc_proxy_channel_.reset( | 788 ipc_proxy_channel_.reset( |
| 791 new IPC::ChannelProxy(channel_handle, | 789 new IPC::ChannelProxy(channel_handle, |
| 792 IPC::Channel::MODE_CLIENT, | 790 IPC::Channel::MODE_CLIENT, |
| 793 &ipc_plugin_listener_, | 791 &ipc_plugin_listener_, |
| 794 base::MessageLoopProxy::current().get())); | 792 base::MessageLoopProxy::current().get())); |
| 795 // Create the browser ppapi host and enable PPAPI message dispatching to the | 793 // Create the browser ppapi host and enable PPAPI message dispatching to the |
| 796 // browser process. | 794 // browser process. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 825 ppapi_host_.get()))); | 823 ppapi_host_.get()))); |
| 826 | 824 |
| 827 // Send a message to create the NaCl-Renderer channel. The handle is just | 825 // Send a message to create the NaCl-Renderer channel. The handle is just |
| 828 // a place holder. | 826 // a place holder. |
| 829 ipc_proxy_channel_->Send( | 827 ipc_proxy_channel_->Send( |
| 830 new PpapiMsg_CreateNaClChannel( | 828 new PpapiMsg_CreateNaClChannel( |
| 831 nacl_host_message_filter_->render_process_id(), | 829 nacl_host_message_filter_->render_process_id(), |
| 832 args, | 830 args, |
| 833 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, | 831 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, |
| 834 IPC::InvalidPlatformFileForTransit()))); | 832 IPC::InvalidPlatformFileForTransit()))); |
| 835 } else if (reply_msg_) { | 833 } else { |
| 836 // Otherwise, this must be a renderer channel. | 834 // Attempt to open more than 1 browser channel is not supported. |
| 835 // Shut down the NaCl process. |
| 836 process_->GetHost()->ForceShutdown(); |
| 837 } |
| 838 } |
| 839 |
| 840 void NaClProcessHost::OnPpapiNaClChannelCreated( |
| 841 const IPC::ChannelHandle& channel_handle) { |
| 842 if (reply_msg_) { |
| 837 ReplyToRenderer(channel_handle); | 843 ReplyToRenderer(channel_handle); |
| 838 } else { | 844 } else { |
| 839 // Attempt to open more than 1 renderer channel is not supported. | 845 // Attempt to open more than 1 renderer channel is not supported. |
| 840 // Shut down the NaCl process. | 846 // Shut down the NaCl process. |
| 841 process_->GetHost()->ForceShutdown(); | 847 process_->GetHost()->ForceShutdown(); |
| 842 } | 848 } |
| 843 } | 849 } |
| 844 | 850 |
| 845 bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) { | 851 bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) { |
| 846 // Handle messages that have been forwarded from our PluginListener. | 852 // Handle messages that have been forwarded from our PluginListener. |
| 847 // These messages come from untrusted code so should be handled with care. | 853 // These messages come from untrusted code so should be handled with care. |
| 848 bool handled = true; | 854 bool handled = true; |
| 849 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) | 855 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) |
| 850 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, | 856 IPC_MESSAGE_HANDLER(PpapiHostMsg_NaClChannelCreated, |
| 851 OnPpapiChannelCreated) | 857 OnPpapiNaClChannelCreated) |
| 852 IPC_MESSAGE_UNHANDLED(handled = false) | 858 IPC_MESSAGE_UNHANDLED(handled = false) |
| 853 IPC_END_MESSAGE_MAP() | 859 IPC_END_MESSAGE_MAP() |
| 854 return handled; | 860 return handled; |
| 855 } | 861 } |
| 856 | 862 |
| 857 bool NaClProcessHost::StartWithLaunchedProcess() { | 863 bool NaClProcessHost::StartWithLaunchedProcess() { |
| 858 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 864 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 859 | 865 |
| 860 if (nacl_browser->IsReady()) { | 866 if (nacl_browser->IsReady()) { |
| 861 return SendStart(); | 867 return SendStart(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 process_handle.Take(), info, | 1027 process_handle.Take(), info, |
| 1022 base::MessageLoopProxy::current(), | 1028 base::MessageLoopProxy::current(), |
| 1023 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1029 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1024 weak_factory_.GetWeakPtr())); | 1030 weak_factory_.GetWeakPtr())); |
| 1025 return true; | 1031 return true; |
| 1026 } | 1032 } |
| 1027 } | 1033 } |
| 1028 #endif | 1034 #endif |
| 1029 | 1035 |
| 1030 } // namespace nacl | 1036 } // namespace nacl |
| OLD | NEW |