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 "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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 #if defined(OS_POSIX) | 763 #if defined(OS_POSIX) |
| 764 if (params.enable_debug_stub) { | 764 if (params.enable_debug_stub) { |
| 765 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); | 765 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); |
| 766 if (server_bound_socket != net::kInvalidSocket) { | 766 if (server_bound_socket != net::kInvalidSocket) { |
| 767 params.debug_stub_server_bound_socket = | 767 params.debug_stub_server_bound_socket = |
| 768 FileDescriptor(server_bound_socket, true); | 768 FileDescriptor(server_bound_socket, true); |
| 769 } | 769 } |
| 770 } | 770 } |
| 771 #endif | 771 #endif |
| 772 | 772 |
| 773 // TODO Propagate command line flags and permissions. | |
| 774 #if 0 | |
| 775 // TODO move to StartNaCl | |
| 776 ppapi::PpapiNaClChannelArgs args; | |
| 777 args.off_the_record = nacl_host_message_filter_->off_the_record(); | |
| 778 args.permissions = permissions_; | |
| 779 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | |
| 780 DCHECK(cmdline); | |
| 781 std::string flag_whitelist[] = { | |
| 782 switches::kPpapiKeepAliveThrottle, | |
| 783 switches::kV, | |
| 784 switches::kVModule, | |
| 785 }; | |
| 786 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { | |
| 787 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); | |
| 788 if (!value.empty()) { | |
| 789 args.switch_names.push_back(flag_whitelist[i]); | |
| 790 args.switch_values.push_back(value); | |
| 791 } | |
| 792 } | |
| 793 #endif | |
| 794 | |
| 773 process_->Send(new NaClProcessMsg_Start(params)); | 795 process_->Send(new NaClProcessMsg_Start(params)); |
| 774 | 796 |
| 775 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; | 797 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; |
| 776 return true; | 798 return true; |
| 777 } | 799 } |
| 778 | 800 |
| 779 bool NaClProcessHost::SendStart() { | 801 bool NaClProcessHost::SendStart() { |
| 780 if (!enable_ppapi_proxy()) { | 802 if (!enable_ppapi_proxy()) { |
| 781 if (!ReplyToRenderer(IPC::ChannelHandle())) | 803 if (!ReplyToRenderer(IPC::ChannelHandle())) |
| 782 return false; | 804 return false; |
| 783 } | 805 } |
| 784 return StartNaClExecution(); | 806 return StartNaClExecution(); |
| 785 } | 807 } |
| 786 | 808 |
| 787 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 809 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 788 // received. | 810 // received. |
| 789 void NaClProcessHost::OnPpapiBrowserChannelCreated( | 811 void NaClProcessHost::OnPpapiBrowserChannelCreated( |
| 790 const IPC::ChannelHandle& channel_handle) { | 812 const IPC::ChannelHandle& browser_channel_handle, |
| 813 const IPC::ChannelHandle& renderer_channel_handle) { | |
| 791 // Only renderer processes should create a channel. | 814 // Only renderer processes should create a channel. |
| 792 DCHECK(enable_ppapi_proxy()); | 815 DCHECK(enable_ppapi_proxy()); |
| 793 if (!ipc_proxy_channel_.get()) { | 816 if (!ipc_proxy_channel_.get()) { |
| 794 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type); | 817 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type); |
| 795 | 818 |
| 796 ipc_proxy_channel_.reset( | 819 ipc_proxy_channel_.reset( |
| 797 new IPC::ChannelProxy(channel_handle, | 820 new IPC::ChannelProxy(browser_channel_handle, |
| 798 IPC::Channel::MODE_CLIENT, | 821 IPC::Channel::MODE_CLIENT, |
| 799 &ipc_plugin_listener_, | 822 &ipc_plugin_listener_, |
| 800 base::MessageLoopProxy::current().get())); | 823 base::MessageLoopProxy::current().get())); |
| 801 // Create the browser ppapi host and enable PPAPI message dispatching to the | 824 // Create the browser ppapi host and enable PPAPI message dispatching to the |
| 802 // browser process. | 825 // browser process. |
| 803 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( | 826 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( |
| 804 ipc_proxy_channel_.get(), // sender | 827 ipc_proxy_channel_.get(), // sender |
| 805 permissions_, | 828 permissions_, |
| 806 process_->GetData().handle, | 829 process_->GetData().handle, |
| 807 ipc_proxy_channel_.get(), | 830 ipc_proxy_channel_.get(), |
| 808 nacl_host_message_filter_->render_process_id(), | 831 nacl_host_message_filter_->render_process_id(), |
| 809 render_view_id_, | 832 render_view_id_, |
| 810 profile_directory_)); | 833 profile_directory_)); |
| 811 ppapi_host_->SetOnKeepaliveCallback( | 834 ppapi_host_->SetOnKeepaliveCallback( |
| 812 NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); | 835 NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); |
| 813 | 836 |
| 814 ppapi::PpapiNaClChannelArgs args; | |
| 815 args.off_the_record = nacl_host_message_filter_->off_the_record(); | |
| 816 args.permissions = permissions_; | |
| 817 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | |
| 818 DCHECK(cmdline); | |
| 819 std::string flag_whitelist[] = { | |
| 820 switches::kPpapiKeepAliveThrottle, | |
| 821 switches::kV, | |
| 822 switches::kVModule, | |
| 823 }; | |
| 824 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { | |
| 825 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); | |
| 826 if (!value.empty()) { | |
| 827 args.switch_names.push_back(flag_whitelist[i]); | |
| 828 args.switch_values.push_back(value); | |
| 829 } | |
| 830 } | |
| 831 | |
| 832 ppapi_host_->GetPpapiHost()->AddHostFactoryFilter( | 837 ppapi_host_->GetPpapiHost()->AddHostFactoryFilter( |
| 833 scoped_ptr<ppapi::host::HostFactory>( | 838 scoped_ptr<ppapi::host::HostFactory>( |
| 834 NaClBrowser::GetDelegate()->CreatePpapiHostFactory( | 839 NaClBrowser::GetDelegate()->CreatePpapiHostFactory( |
| 835 ppapi_host_.get()))); | 840 ppapi_host_.get()))); |
| 836 | 841 |
| 837 // Send a message to create the NaCl-Renderer channel. The handle is just | 842 ReplyToRenderer(renderer_channel_handle); |
| 838 // a place holder. | |
| 839 ipc_proxy_channel_->Send( | |
| 840 new PpapiMsg_CreateNaClChannel( | |
|
Mark Seaborn
2014/02/04 01:18:31
I think you will want to keep the PpapiMsg_CreateN
| |
| 841 args, | |
| 842 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, | |
| 843 IPC::InvalidPlatformFileForTransit()))); | |
| 844 } else { | 843 } else { |
| 845 // Attempt to open more than 1 browser channel is not supported. | 844 // Attempt to open more than 1 browser channel is not supported. |
| 846 // Shut down the NaCl process. | 845 // Shut down the NaCl process. |
| 847 process_->GetHost()->ForceShutdown(); | 846 process_->GetHost()->ForceShutdown(); |
| 848 } | 847 } |
| 849 } | 848 } |
| 850 | 849 |
| 851 void NaClProcessHost::OnPpapiRendererChannelCreated( | 850 void NaClProcessHost::OnPpapiRendererChannelCreated( |
|
Mark Seaborn
2014/02/03 22:59:07
This method should go away, right?
| |
| 852 const IPC::ChannelHandle& channel_handle) { | 851 const IPC::ChannelHandle& channel_handle) { |
| 853 if (reply_msg_) { | 852 if (reply_msg_) { |
| 854 ReplyToRenderer(channel_handle); | 853 ReplyToRenderer(channel_handle); |
| 855 } else { | 854 } else { |
| 856 // Attempt to open more than 1 NaCl renderer channel is not supported. | 855 // Attempt to open more than 1 NaCl renderer channel is not supported. |
| 857 // Shut down the NaCl process. | 856 // Shut down the NaCl process. |
| 858 process_->GetHost()->ForceShutdown(); | 857 process_->GetHost()->ForceShutdown(); |
| 859 } | 858 } |
| 860 } | 859 } |
| 861 | 860 |
| 862 bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) { | 861 bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) { |
|
Mark Seaborn
2014/02/03 22:59:07
I think this should go away too, since it only han
| |
| 863 // Handle messages that have been forwarded from our PluginListener. | 862 // Handle messages that have been forwarded from our PluginListener. |
| 864 // These messages come from untrusted code so should be handled with care. | 863 // These messages come from untrusted code so should be handled with care. |
| 865 bool handled = true; | 864 bool handled = true; |
| 866 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) | 865 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) |
| 867 IPC_MESSAGE_HANDLER(PpapiHostMsg_NaClChannelCreated, | 866 IPC_MESSAGE_HANDLER(PpapiHostMsg_NaClChannelCreated, |
| 868 OnPpapiRendererChannelCreated) | 867 OnPpapiRendererChannelCreated) |
| 869 IPC_MESSAGE_UNHANDLED(handled = false) | 868 IPC_MESSAGE_UNHANDLED(handled = false) |
| 870 IPC_END_MESSAGE_MAP() | 869 IPC_END_MESSAGE_MAP() |
| 871 return handled; | 870 return handled; |
| 872 } | 871 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 process_handle.Take(), info, | 1037 process_handle.Take(), info, |
| 1039 base::MessageLoopProxy::current(), | 1038 base::MessageLoopProxy::current(), |
| 1040 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1039 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1041 weak_factory_.GetWeakPtr())); | 1040 weak_factory_.GetWeakPtr())); |
| 1042 return true; | 1041 return true; |
| 1043 } | 1042 } |
| 1044 } | 1043 } |
| 1045 #endif | 1044 #endif |
| 1046 | 1045 |
| 1047 } // namespace nacl | 1046 } // namespace nacl |
| OLD | NEW |