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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 : socket_for_renderer(NACL_INVALID_HANDLE), | 242 : socket_for_renderer(NACL_INVALID_HANDLE), |
243 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } | 243 socket_for_sel_ldr(NACL_INVALID_HANDLE) { } |
244 }; | 244 }; |
245 | 245 |
246 // ----------------------------------------------------------------------------- | 246 // ----------------------------------------------------------------------------- |
247 | 247 |
248 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 248 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
249 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 249 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
250 | 250 |
251 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 251 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, |
| 252 base::File nexe_file, |
252 ppapi::PpapiPermissions permissions, | 253 ppapi::PpapiPermissions permissions, |
253 int render_view_id, | 254 int render_view_id, |
254 uint32 permission_bits, | 255 uint32 permission_bits, |
255 bool uses_irt, | 256 bool uses_irt, |
256 bool uses_nonsfi_mode, | 257 bool uses_nonsfi_mode, |
257 bool enable_dyncode_syscalls, | 258 bool enable_dyncode_syscalls, |
258 bool enable_exception_handling, | 259 bool enable_exception_handling, |
259 bool enable_crash_throttling, | 260 bool enable_crash_throttling, |
260 bool off_the_record, | 261 bool off_the_record, |
261 const base::FilePath& profile_directory) | 262 const base::FilePath& profile_directory) |
262 : manifest_url_(manifest_url), | 263 : manifest_url_(manifest_url), |
| 264 nexe_file_(nexe_file.Pass()), |
263 permissions_(permissions), | 265 permissions_(permissions), |
264 #if defined(OS_WIN) | 266 #if defined(OS_WIN) |
265 process_launched_by_broker_(false), | 267 process_launched_by_broker_(false), |
266 #endif | 268 #endif |
267 reply_msg_(NULL), | 269 reply_msg_(NULL), |
268 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
269 debug_exception_handler_requested_(false), | 271 debug_exception_handler_requested_(false), |
270 #endif | 272 #endif |
271 internal_(new NaClInternal()), | 273 internal_(new NaClInternal()), |
272 weak_factory_(this), | 274 weak_factory_(this), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 443 |
442 if (!nonsfi_mode_enabled) { | 444 if (!nonsfi_mode_enabled) { |
443 SendErrorToRenderer( | 445 SendErrorToRenderer( |
444 "NaCl non-SFI mode is not available for this platform" | 446 "NaCl non-SFI mode is not available for this platform" |
445 " and NaCl module."); | 447 " and NaCl module."); |
446 delete this; | 448 delete this; |
447 return; | 449 return; |
448 } | 450 } |
449 } | 451 } |
450 | 452 |
| 453 // TODO(hidehiko): We no longer use imc socket channel for non-SFI mode. |
| 454 // Do not create it. |
| 455 |
451 // Rather than creating a socket pair in the renderer, and passing | 456 // Rather than creating a socket pair in the renderer, and passing |
452 // one side through the browser to sel_ldr, socket pairs are created | 457 // one side through the browser to sel_ldr, socket pairs are created |
453 // in the browser and then passed to the renderer and sel_ldr. | 458 // in the browser and then passed to the renderer and sel_ldr. |
454 // | 459 // |
455 // This is mainly for the benefit of Windows, where sockets cannot | 460 // This is mainly for the benefit of Windows, where sockets cannot |
456 // be passed in messages, but are copied via DuplicateHandle(). | 461 // be passed in messages, but are copied via DuplicateHandle(). |
457 // This means the sandboxed renderer cannot send handles to the | 462 // This means the sandboxed renderer cannot send handles to the |
458 // browser process. | 463 // browser process. |
459 | 464 |
460 NaClHandle pair[2]; | 465 NaClHandle pair[2]; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 void NaClProcessHost::OnDebugStubPortSelected(uint16_t debug_stub_port) { | 810 void NaClProcessHost::OnDebugStubPortSelected(uint16_t debug_stub_port) { |
806 CHECK(!uses_nonsfi_mode_); | 811 CHECK(!uses_nonsfi_mode_); |
807 SetDebugStubPort(debug_stub_port); | 812 SetDebugStubPort(debug_stub_port); |
808 } | 813 } |
809 #endif | 814 #endif |
810 | 815 |
811 bool NaClProcessHost::StartNaClExecution() { | 816 bool NaClProcessHost::StartNaClExecution() { |
812 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 817 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
813 | 818 |
814 NaClStartParams params; | 819 NaClStartParams params; |
| 820 |
815 // Enable PPAPI proxy channel creation only for renderer processes. | 821 // Enable PPAPI proxy channel creation only for renderer processes. |
816 params.enable_ipc_proxy = enable_ppapi_proxy(); | 822 params.enable_ipc_proxy = enable_ppapi_proxy(); |
817 if (!uses_nonsfi_mode_) { | 823 if (uses_nonsfi_mode_) { |
| 824 // Currently, non-SFI mode is supported only on Linux. |
| 825 #if defined(OS_LINUX) |
| 826 // nexe_file_ still keeps the ownership at this moment, because |params| |
| 827 // may just be destroyed before sending IPC is properly processed. |
| 828 // Note that although we set auto_close=true for FileDescriptor's |
| 829 // constructor, it is not automatically handled in its destructor as RAII. |
| 830 params.nexe_file = |
| 831 base::FileDescriptor(nexe_file_.GetPlatformFile(), true); |
| 832 #endif |
| 833 } else { |
818 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); | 834 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); |
819 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); | 835 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); |
820 params.version = NaClBrowser::GetDelegate()->GetVersionString(); | 836 params.version = NaClBrowser::GetDelegate()->GetVersionString(); |
821 params.enable_exception_handling = enable_exception_handling_; | 837 params.enable_exception_handling = enable_exception_handling_; |
822 params.enable_debug_stub = enable_debug_stub_ && | 838 params.enable_debug_stub = enable_debug_stub_ && |
823 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); | 839 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); |
824 params.uses_irt = uses_irt_; | 840 params.uses_irt = uses_irt_; |
825 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; | 841 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; |
826 } | 842 } |
827 | 843 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 #if defined(OS_POSIX) | 884 #if defined(OS_POSIX) |
869 if (params.enable_debug_stub) { | 885 if (params.enable_debug_stub) { |
870 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); | 886 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); |
871 if (server_bound_socket != net::kInvalidSocket) { | 887 if (server_bound_socket != net::kInvalidSocket) { |
872 params.debug_stub_server_bound_socket = | 888 params.debug_stub_server_bound_socket = |
873 FileDescriptor(server_bound_socket, true); | 889 FileDescriptor(server_bound_socket, true); |
874 } | 890 } |
875 } | 891 } |
876 #endif | 892 #endif |
877 | 893 |
| 894 // Here we are about to send the IPC, so release file descriptors to delegate |
| 895 // the ownership to the message. |
| 896 if (uses_nonsfi_mode_) { |
| 897 nexe_file_.TakePlatformFile(); |
| 898 } |
| 899 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; |
| 900 |
878 process_->Send(new NaClProcessMsg_Start(params)); | 901 process_->Send(new NaClProcessMsg_Start(params)); |
879 | |
880 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; | |
881 return true; | 902 return true; |
882 } | 903 } |
883 | 904 |
884 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 905 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
885 // received. | 906 // received. |
886 void NaClProcessHost::OnPpapiChannelsCreated( | 907 void NaClProcessHost::OnPpapiChannelsCreated( |
887 const IPC::ChannelHandle& browser_channel_handle, | 908 const IPC::ChannelHandle& browser_channel_handle, |
888 const IPC::ChannelHandle& ppapi_renderer_channel_handle, | 909 const IPC::ChannelHandle& ppapi_renderer_channel_handle, |
889 const IPC::ChannelHandle& trusted_renderer_channel_handle, | 910 const IPC::ChannelHandle& trusted_renderer_channel_handle, |
890 const IPC::ChannelHandle& manifest_service_channel_handle) { | 911 const IPC::ChannelHandle& manifest_service_channel_handle) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 process_handle.Take(), info, | 1145 process_handle.Take(), info, |
1125 base::MessageLoopProxy::current(), | 1146 base::MessageLoopProxy::current(), |
1126 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1147 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1127 weak_factory_.GetWeakPtr())); | 1148 weak_factory_.GetWeakPtr())); |
1128 return true; | 1149 return true; |
1129 } | 1150 } |
1130 } | 1151 } |
1131 #endif | 1152 #endif |
1132 | 1153 |
1133 } // namespace nacl | 1154 } // namespace nacl |
OLD | NEW |