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::ResourceFileInfo::ResourceFileInfo() |
239 base::File nexe_file, | 239 : file_token_() { |
240 const NaClFileToken& nexe_token, | 240 } |
241 ppapi::PpapiPermissions permissions, | 241 |
242 int render_view_id, | 242 NaClProcessHost::ResourceFileInfo::ResourceFileInfo( |
243 uint32 permission_bits, | 243 base::File file, |
244 bool uses_nonsfi_mode, | 244 const NaClFileToken& file_token, |
245 bool off_the_record, | 245 const std::string& file_key) |
246 NaClAppProcessType process_type, | 246 : file_(file.Pass()), |
247 const base::FilePath& profile_directory) | 247 file_token_(file_token), |
248 file_key_(file_key) { | |
249 } | |
250 | |
251 NaClProcessHost::ResourceFileInfo::~ResourceFileInfo() { | |
252 } | |
253 | |
254 NaClProcessHost::ResourceFileInfo::ResourceFileInfo(RValue other) | |
255 : file_(other.object->file_.Pass()), | |
256 file_token_(other.object->file_token()), | |
257 file_key_(other.object->file_key()) { | |
258 } | |
259 | |
260 NaClProcessHost::ResourceFileInfo& | |
261 NaClProcessHost::ResourceFileInfo::operator=(RValue other) { | |
262 if (this != other.object) { | |
263 file_ = other.object->file_.Pass(); | |
264 file_token_ = other.object->file_token(); | |
265 file_key_ = other.object->file_key(); | |
266 } | |
267 return *this; | |
268 } | |
269 | |
270 NaClProcessHost::NaClProcessHost( | |
271 const GURL& manifest_url, | |
272 base::File nexe_file, | |
273 const NaClFileToken& nexe_token, | |
274 scoped_ptr<NaClProcessHost::ResourceFileInfo[]> resource_files_info, | |
275 size_t resource_files_info_len, | |
276 ppapi::PpapiPermissions permissions, | |
277 int render_view_id, | |
278 uint32 permission_bits, | |
279 bool uses_nonsfi_mode, | |
280 bool off_the_record, | |
281 NaClAppProcessType process_type, | |
282 const base::FilePath& profile_directory) | |
248 : manifest_url_(manifest_url), | 283 : manifest_url_(manifest_url), |
249 nexe_file_(nexe_file.Pass()), | 284 nexe_file_(nexe_file.Pass()), |
250 nexe_token_(nexe_token), | 285 nexe_token_(nexe_token), |
286 resource_files_info_(resource_files_info.Pass()), | |
287 resource_files_info_len_(resource_files_info_len), | |
251 permissions_(permissions), | 288 permissions_(permissions), |
252 #if defined(OS_WIN) | 289 #if defined(OS_WIN) |
253 process_launched_by_broker_(false), | 290 process_launched_by_broker_(false), |
254 #endif | 291 #endif |
255 reply_msg_(NULL), | 292 reply_msg_(NULL), |
256 #if defined(OS_WIN) | 293 #if defined(OS_WIN) |
257 debug_exception_handler_requested_(false), | 294 debug_exception_handler_requested_(false), |
258 #endif | 295 #endif |
259 uses_nonsfi_mode_(uses_nonsfi_mode), | 296 uses_nonsfi_mode_(uses_nonsfi_mode), |
260 enable_debug_stub_(false), | 297 enable_debug_stub_(false), |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
873 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 910 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, |
874 ¶ms.crash_info_shmem_handle)) { | 911 ¶ms.crash_info_shmem_handle)) { |
875 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 912 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; |
876 return false; | 913 return false; |
877 } | 914 } |
878 | 915 |
879 base::FilePath file_path; | 916 base::FilePath file_path; |
880 // Don't retrieve the file path when using nonsfi mode; there's no validation | 917 // Don't retrieve the file path when using nonsfi mode; there's no validation |
881 // caching in that case, so it's unnecessary work, and would expose the file | 918 // caching in that case, so it's unnecessary work, and would expose the file |
882 // path to the plugin. | 919 // path to the plugin. |
883 if (!uses_nonsfi_mode_ && | 920 if (uses_nonsfi_mode_) { |
hidehiko
2015/01/28 09:05:19
nit:
if (nonsfi) {
// Don't retrieve the file p
Yusuke Sato
2015/02/04 02:00:28
Done.
| |
884 NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | 921 for (size_t i = 0; i < resource_files_info_len_; ++i) { |
hidehiko
2015/01/28 09:05:19
Could you add a short comment why this is needed o
Yusuke Sato
2015/02/04 02:00:28
Done.
| |
885 nexe_token_.hi, | 922 IPC::PlatformFileForTransit file = IPC::TakeFileHandleForProcess( |
886 &file_path)) { | 923 resource_files_info_[i].file().Pass(), process_->GetData().handle); |
924 std::string file_key = resource_files_info_[i].file_key(); | |
925 params.resource_files.push_back( | |
926 // Pass an empty base::FilePath since Non-SFI mode does not use it. | |
927 NaClStartParams::ResourceFileInfo(file, base::FilePath(), file_key)); | |
928 } | |
929 } else if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | |
930 nexe_token_.hi, | |
931 &file_path)) { | |
887 // We have to reopen the file in the browser process; we don't want a | 932 // We have to reopen the file in the browser process; we don't want a |
888 // compromised renderer to pass an arbitrary fd that could get loaded | 933 // compromised renderer to pass an arbitrary fd that could get loaded |
889 // into the plugin process. | 934 // into the plugin process. |
890 if (base::PostTaskAndReplyWithResult( | 935 if (base::PostTaskAndReplyWithResult( |
891 content::BrowserThread::GetBlockingPool(), | 936 content::BrowserThread::GetBlockingPool(), |
892 FROM_HERE, | 937 FROM_HERE, |
893 base::Bind(OpenNaClReadExecImpl, | 938 base::Bind(OpenNaClReadExecImpl, |
894 file_path, | 939 file_path, |
895 true /* is_executable */), | 940 true /* is_executable */), |
896 base::Bind(&NaClProcessHost::StartNaClFileResolved, | 941 base::Bind(&NaClProcessHost::StartNaClFileResolved, |
897 weak_factory_.GetWeakPtr(), | 942 weak_factory_.GetWeakPtr(), |
898 params, | 943 params, |
899 file_path))) { | 944 file_path))) { |
900 return true; | 945 return true; |
901 } | 946 } |
902 } | 947 } |
903 | 948 |
904 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 949 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
905 process_->GetData().handle); | 950 process_->GetData().handle); |
951 | |
952 params.CheckNumOfDescriptors(); | |
906 process_->Send(new NaClProcessMsg_Start(params)); | 953 process_->Send(new NaClProcessMsg_Start(params)); |
907 return true; | 954 return true; |
908 } | 955 } |
909 | 956 |
910 void NaClProcessHost::StartNaClFileResolved( | 957 void NaClProcessHost::StartNaClFileResolved( |
911 NaClStartParams params, | 958 NaClStartParams params, |
912 const base::FilePath& file_path, | 959 const base::FilePath& file_path, |
913 base::File checked_nexe_file) { | 960 base::File checked_nexe_file) { |
914 if (checked_nexe_file.IsValid()) { | 961 if (checked_nexe_file.IsValid()) { |
915 // Release the file received from the renderer. This has to be done on a | 962 // Release the file received from the renderer. This has to be done on a |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 process_handle.Take(), info, | 1220 process_handle.Take(), info, |
1174 base::MessageLoopProxy::current(), | 1221 base::MessageLoopProxy::current(), |
1175 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1222 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1176 weak_factory_.GetWeakPtr())); | 1223 weak_factory_.GetWeakPtr())); |
1177 return true; | 1224 return true; |
1178 } | 1225 } |
1179 } | 1226 } |
1180 #endif | 1227 #endif |
1181 | 1228 |
1182 } // namespace nacl | 1229 } // namespace nacl |
OLD | NEW |