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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 | 228 |
| 229 void CloseFile(base::File file) { | 229 void CloseFile(base::File file) { |
| 230 // The base::File destructor will close the file for us. | 230 // The base::File destructor will close the file for us. |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace | 233 } // namespace |
| 234 | 234 |
| 235 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = | 235 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = |
| 236 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; | 236 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; |
| 237 | 237 |
| 238 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 238 NaClProcessHost::NaClProcessHost( |
| 239 base::File nexe_file, | 239 const GURL& manifest_url, |
| 240 const NaClFileToken& nexe_token, | 240 base::File nexe_file, |
| 241 ppapi::PpapiPermissions permissions, | 241 const NaClFileToken& nexe_token, |
| 242 int render_view_id, | 242 const std::vector<NaClResourceFileInfo>& resource_files_info, |
|
Mark Seaborn
2015/02/12 03:57:33
I walked through the IPC flow to refresh my memory
Yusuke Sato
2015/02/13 23:01:16
I didn't do this originally mainly because I wante
| |
| 243 uint32 permission_bits, | 243 ppapi::PpapiPermissions permissions, |
| 244 bool uses_nonsfi_mode, | 244 int render_view_id, |
| 245 bool off_the_record, | 245 uint32 permission_bits, |
| 246 NaClAppProcessType process_type, | 246 bool uses_nonsfi_mode, |
| 247 const base::FilePath& profile_directory) | 247 bool off_the_record, |
| 248 NaClAppProcessType process_type, | |
| 249 const base::FilePath& profile_directory) | |
| 248 : manifest_url_(manifest_url), | 250 : manifest_url_(manifest_url), |
| 249 nexe_file_(nexe_file.Pass()), | 251 nexe_file_(nexe_file.Pass()), |
| 250 nexe_token_(nexe_token), | 252 nexe_token_(nexe_token), |
| 253 resource_files_info_(resource_files_info), | |
| 251 permissions_(permissions), | 254 permissions_(permissions), |
| 252 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
| 253 process_launched_by_broker_(false), | 256 process_launched_by_broker_(false), |
| 254 #endif | 257 #endif |
| 255 reply_msg_(NULL), | 258 reply_msg_(NULL), |
| 256 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
| 257 debug_exception_handler_requested_(false), | 260 debug_exception_handler_requested_(false), |
| 258 #endif | 261 #endif |
| 259 uses_nonsfi_mode_(uses_nonsfi_mode), | 262 uses_nonsfi_mode_(uses_nonsfi_mode), |
| 260 enable_debug_stub_(false), | 263 enable_debug_stub_(false), |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 #endif | 882 #endif |
| 880 } | 883 } |
| 881 | 884 |
| 882 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 885 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, |
| 883 ¶ms.crash_info_shmem_handle)) { | 886 ¶ms.crash_info_shmem_handle)) { |
| 884 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 887 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; |
| 885 return false; | 888 return false; |
| 886 } | 889 } |
| 887 | 890 |
| 888 base::FilePath file_path; | 891 base::FilePath file_path; |
| 889 // Don't retrieve the file path when using nonsfi mode; there's no validation | 892 if (uses_nonsfi_mode_) { |
| 890 // caching in that case, so it's unnecessary work, and would expose the file | 893 // Don't retrieve the file path when using nonsfi mode; there's no |
| 891 // path to the plugin. | 894 // validation caching in that case, so it's unnecessary work, and would |
| 892 if (!uses_nonsfi_mode_ && | 895 // expose the file path to the plugin. |
| 893 NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | 896 for (size_t i = 0; i < resource_files_info_.size(); ++i) { |
| 894 nexe_token_.hi, | 897 params.resource_files.push_back( |
| 895 &file_path)) { | 898 NaClStartParams::ResourceFileInfo(resource_files_info_[i].file, |
| 896 // We have to reopen the file in the browser process; we don't want a | 899 base::FilePath(), |
|
Mark Seaborn
2015/02/12 03:57:33
See comment in nonsfi_listener.cc -- you can add a
Yusuke Sato
2015/02/13 23:01:16
Done.
| |
| 897 // compromised renderer to pass an arbitrary fd that could get loaded | 900 resource_files_info_[i].key)); |
| 898 // into the plugin process. | |
| 899 if (base::PostTaskAndReplyWithResult( | |
| 900 content::BrowserThread::GetBlockingPool(), | |
| 901 FROM_HERE, | |
| 902 base::Bind(OpenNaClReadExecImpl, | |
| 903 file_path, | |
| 904 true /* is_executable */), | |
| 905 base::Bind(&NaClProcessHost::StartNaClFileResolved, | |
| 906 weak_factory_.GetWeakPtr(), | |
| 907 params, | |
| 908 file_path))) { | |
| 909 return true; | |
| 910 } | 901 } |
| 902 } else { | |
| 903 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | |
| 904 nexe_token_.hi, | |
| 905 &file_path)) { | |
| 906 // We have to reopen the file in the browser process; we don't want a | |
| 907 // compromised renderer to pass an arbitrary fd that could get loaded | |
| 908 // into the plugin process. | |
| 909 if (base::PostTaskAndReplyWithResult( | |
| 910 content::BrowserThread::GetBlockingPool(), | |
| 911 FROM_HERE, | |
| 912 base::Bind(OpenNaClReadExecImpl, | |
| 913 file_path, | |
| 914 true /* is_executable */), | |
| 915 base::Bind(&NaClProcessHost::StartNaClFileResolved, | |
| 916 weak_factory_.GetWeakPtr(), | |
| 917 params, | |
| 918 file_path))) { | |
| 919 return true; | |
| 920 } | |
| 921 } | |
| 922 // TODO(yusukes): Handle |resource_files_info_| for SFI-NaCl. | |
| 911 } | 923 } |
| 912 | 924 |
| 913 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 925 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
| 914 process_->GetData().handle); | 926 process_->GetData().handle); |
| 927 | |
| 928 params.CheckNumOfDescriptors(); | |
| 915 process_->Send(new NaClProcessMsg_Start(params)); | 929 process_->Send(new NaClProcessMsg_Start(params)); |
| 916 return true; | 930 return true; |
| 917 } | 931 } |
| 918 | 932 |
| 919 void NaClProcessHost::StartNaClFileResolved( | 933 void NaClProcessHost::StartNaClFileResolved( |
| 920 NaClStartParams params, | 934 NaClStartParams params, |
| 921 const base::FilePath& file_path, | 935 const base::FilePath& file_path, |
| 922 base::File checked_nexe_file) { | 936 base::File checked_nexe_file) { |
| 923 if (checked_nexe_file.IsValid()) { | 937 if (checked_nexe_file.IsValid()) { |
| 924 // Release the file received from the renderer. This has to be done on a | 938 // Release the file received from the renderer. This has to be done on a |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 process.Pass(), info, | 1194 process.Pass(), info, |
| 1181 base::MessageLoopProxy::current(), | 1195 base::MessageLoopProxy::current(), |
| 1182 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1196 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1183 weak_factory_.GetWeakPtr())); | 1197 weak_factory_.GetWeakPtr())); |
| 1184 return true; | 1198 return true; |
| 1185 } | 1199 } |
| 1186 } | 1200 } |
| 1187 #endif | 1201 #endif |
| 1188 | 1202 |
| 1189 } // namespace nacl | 1203 } // namespace nacl |
| OLD | NEW |