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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 base::File nexe_file, |
| 253 uint64_t nexe_token_lo, | |
| 254 uint64_t nexe_token_hi, | |
| 253 ppapi::PpapiPermissions permissions, | 255 ppapi::PpapiPermissions permissions, |
| 254 int render_view_id, | 256 int render_view_id, |
| 255 uint32 permission_bits, | 257 uint32 permission_bits, |
| 256 bool uses_irt, | 258 bool uses_irt, |
| 257 bool uses_nonsfi_mode, | 259 bool uses_nonsfi_mode, |
| 258 bool enable_dyncode_syscalls, | 260 bool enable_dyncode_syscalls, |
| 259 bool enable_exception_handling, | 261 bool enable_exception_handling, |
| 260 bool enable_crash_throttling, | 262 bool enable_crash_throttling, |
| 261 bool off_the_record, | 263 bool off_the_record, |
| 262 const base::FilePath& profile_directory) | 264 const base::FilePath& profile_directory) |
| 263 : manifest_url_(manifest_url), | 265 : manifest_url_(manifest_url), |
| 264 nexe_file_(nexe_file.Pass()), | 266 nexe_file_(nexe_file.Pass()), |
| 267 nexe_token_lo_(nexe_token_lo), | |
| 268 nexe_token_hi_(nexe_token_hi), | |
| 265 permissions_(permissions), | 269 permissions_(permissions), |
| 266 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
| 267 process_launched_by_broker_(false), | 271 process_launched_by_broker_(false), |
| 268 #endif | 272 #endif |
| 269 reply_msg_(NULL), | 273 reply_msg_(NULL), |
| 270 #if defined(OS_WIN) | 274 #if defined(OS_WIN) |
| 271 debug_exception_handler_requested_(false), | 275 debug_exception_handler_requested_(false), |
| 272 #endif | 276 #endif |
| 273 internal_(new NaClInternal()), | 277 internal_(new NaClInternal()), |
| 274 weak_factory_(this), | 278 weak_factory_(this), |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 } | 814 } |
| 811 #endif | 815 #endif |
| 812 | 816 |
| 813 bool NaClProcessHost::StartNaClExecution() { | 817 bool NaClProcessHost::StartNaClExecution() { |
| 814 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 818 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 815 | 819 |
| 816 NaClStartParams params; | 820 NaClStartParams params; |
| 817 | 821 |
| 818 // Enable PPAPI proxy channel creation only for renderer processes. | 822 // Enable PPAPI proxy channel creation only for renderer processes. |
| 819 params.enable_ipc_proxy = enable_ppapi_proxy(); | 823 params.enable_ipc_proxy = enable_ppapi_proxy(); |
| 824 // nexe_file_ still keeps the ownership at this moment, because |params| | |
| 825 // may just be destroyed before sending IPC is properly processed. | |
| 826 // Note that although we set auto_close=true for FileDescriptor's | |
| 827 // constructor, it is not automatically handled in its destructor as RAII. | |
| 828 #if defined(OS_POSIX) | |
| 829 params.nexe_file = | |
| 830 base::FileDescriptor(nexe_file_.GetPlatformFile(), true); | |
| 831 #else | |
|
bbudge
2014/06/30 18:28:53
nit: #elif defined(OS_WIN) to make this a little m
teravest
2014/06/30 22:04:55
Done.
| |
| 832 // Duplicate the handle from the renderer to the plugin process. | |
| 833 if (!::DuplicateHandle(nacl_host_message_filter_->PeerHandle(), | |
| 834 nexe_file_.GetPlatformFile(), | |
| 835 process_->GetData().handle, | |
| 836 ¶ms.nexe_file, | |
| 837 0, // Unused, given DUPLICATE_SAME_ACCESS. | |
| 838 FALSE, | |
| 839 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) | |
| 840 return false; | |
| 841 #endif | |
| 842 | |
| 820 if (uses_nonsfi_mode_) { | 843 if (uses_nonsfi_mode_) { |
| 821 // Currently, non-SFI mode is supported only on Linux. | 844 // Currently, non-SFI mode is supported only on Linux. |
| 822 #if defined(OS_LINUX) | 845 #if defined(OS_LINUX) |
| 823 // nexe_file_ still keeps the ownership at this moment, because |params| | |
| 824 // may just be destroyed before sending IPC is properly processed. | |
| 825 // Note that although we set auto_close=true for FileDescriptor's | |
| 826 // constructor, it is not automatically handled in its destructor as RAII. | |
| 827 params.nexe_file = | |
| 828 base::FileDescriptor(nexe_file_.GetPlatformFile(), true); | |
| 829 // In non-SFI mode, we do not use SRPC. Make sure that the socketpair is | 846 // In non-SFI mode, we do not use SRPC. Make sure that the socketpair is |
| 830 // not created. | 847 // not created. |
| 831 DCHECK_EQ(internal_->socket_for_sel_ldr, NACL_INVALID_HANDLE); | 848 DCHECK_EQ(internal_->socket_for_sel_ldr, NACL_INVALID_HANDLE); |
| 832 #endif | 849 #endif |
| 833 } else { | 850 } else { |
| 834 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); | 851 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); |
| 835 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); | 852 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); |
| 836 params.version = NaClBrowser::GetDelegate()->GetVersionString(); | 853 params.version = NaClBrowser::GetDelegate()->GetVersionString(); |
| 837 params.enable_exception_handling = enable_exception_handling_; | 854 params.enable_exception_handling = enable_exception_handling_; |
| 838 params.enable_debug_stub = enable_debug_stub_ && | 855 params.enable_debug_stub = enable_debug_stub_ && |
| 839 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); | 856 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); |
| 840 params.uses_irt = uses_irt_; | 857 params.uses_irt = uses_irt_; |
| 841 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; | 858 params.enable_dyncode_syscalls = enable_dyncode_syscalls_; |
| 842 | 859 |
| 860 params.nexe_token_lo = nexe_token_lo_; | |
| 861 params.nexe_token_hi = nexe_token_hi_; | |
| 862 | |
| 843 const ChildProcessData& data = process_->GetData(); | 863 const ChildProcessData& data = process_->GetData(); |
| 844 if (!ShareHandleToSelLdr(data.handle, | 864 if (!ShareHandleToSelLdr(data.handle, |
| 845 internal_->socket_for_sel_ldr, true, | 865 internal_->socket_for_sel_ldr, true, |
| 846 ¶ms.handles)) { | 866 ¶ms.handles)) { |
| 847 return false; | 867 return false; |
| 848 } | 868 } |
| 849 | 869 |
| 850 if (params.uses_irt) { | 870 if (params.uses_irt) { |
| 851 const base::File& irt_file = nacl_browser->IrtFile(); | 871 const base::File& irt_file = nacl_browser->IrtFile(); |
| 852 CHECK(irt_file.IsValid()); | 872 CHECK(irt_file.IsValid()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 if (server_bound_socket != net::kInvalidSocket) { | 906 if (server_bound_socket != net::kInvalidSocket) { |
| 887 params.debug_stub_server_bound_socket = | 907 params.debug_stub_server_bound_socket = |
| 888 FileDescriptor(server_bound_socket, true); | 908 FileDescriptor(server_bound_socket, true); |
| 889 } | 909 } |
| 890 } | 910 } |
| 891 #endif | 911 #endif |
| 892 } | 912 } |
| 893 | 913 |
| 894 // Here we are about to send the IPC, so release file descriptors to delegate | 914 // Here we are about to send the IPC, so release file descriptors to delegate |
| 895 // the ownership to the message. | 915 // the ownership to the message. |
| 896 if (uses_nonsfi_mode_) { | 916 nexe_file_.TakePlatformFile(); |
| 897 nexe_file_.TakePlatformFile(); | 917 |
|
Mark Seaborn
2014/06/30 20:01:03
Nit: remove empty line to make it clear that the c
teravest
2014/06/30 22:04:55
Done.
| |
| 898 } else { | 918 if (!uses_nonsfi_mode_) { |
| 899 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; | 919 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; |
| 900 } | 920 } |
| 901 | 921 |
| 902 process_->Send(new NaClProcessMsg_Start(params)); | 922 process_->Send(new NaClProcessMsg_Start(params)); |
| 903 return true; | 923 return true; |
| 904 } | 924 } |
| 905 | 925 |
| 906 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 926 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 907 // received. | 927 // received. |
| 908 void NaClProcessHost::OnPpapiChannelsCreated( | 928 void NaClProcessHost::OnPpapiChannelsCreated( |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 process_handle.Take(), info, | 1166 process_handle.Take(), info, |
| 1147 base::MessageLoopProxy::current(), | 1167 base::MessageLoopProxy::current(), |
| 1148 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1168 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1149 weak_factory_.GetWeakPtr())); | 1169 weak_factory_.GetWeakPtr())); |
| 1150 return true; | 1170 return true; |
| 1151 } | 1171 } |
| 1152 } | 1172 } |
| 1153 #endif | 1173 #endif |
| 1154 | 1174 |
| 1155 } // namespace nacl | 1175 } // namespace nacl |
| OLD | NEW |