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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 exit_code, exit_code); | 260 exit_code, exit_code); |
261 if (exit_code == 0) { | 261 if (exit_code == 0) { |
262 VLOG(1) << message; | 262 VLOG(1) << message; |
263 } else { | 263 } else { |
264 LOG(ERROR) << message; | 264 LOG(ERROR) << message; |
265 } | 265 } |
266 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id); | 266 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id); |
267 } | 267 } |
268 | 268 |
269 // Note: this does not work on Windows, though we currently support this | 269 // Note: this does not work on Windows, though we currently support this |
270 // prefetching feature only on Non-SFI mode, which is supported only on | 270 // prefetching feature only on POSIX platforms, so it should be ok. |
271 // Linux/ChromeOS, so it should be ok. | |
272 #if defined(OS_WIN) | 271 #if defined(OS_WIN) |
273 DCHECK(prefetched_resource_files_.empty()); | 272 DCHECK(prefetched_resource_files_.empty()); |
274 #else | 273 #else |
275 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { | 274 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { |
276 // The process failed to launch for some reason. Close resource file | 275 // The process failed to launch for some reason. Close resource file |
277 // handles. | 276 // handles. |
278 base::File file(IPC::PlatformFileForTransitToFile( | 277 base::File file(IPC::PlatformFileForTransitToFile( |
279 prefetched_resource_files_[i].file)); | 278 prefetched_resource_files_[i].file)); |
280 content::BrowserThread::GetBlockingPool()->PostTask( | 279 content::BrowserThread::GetBlockingPool()->PostTask( |
281 FROM_HERE, | 280 FROM_HERE, |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 } | 863 } |
865 #endif | 864 #endif |
866 } | 865 } |
867 | 866 |
868 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 867 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, |
869 ¶ms.crash_info_shmem_handle)) { | 868 ¶ms.crash_info_shmem_handle)) { |
870 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 869 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; |
871 return false; | 870 return false; |
872 } | 871 } |
873 | 872 |
| 873 // Pass the pre-opened resource files to the loader. We do not have to reopen |
| 874 // resource files here even for SFI mode because the descriptors are not from |
| 875 // a renderer. |
| 876 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { |
| 877 params.prefetched_resource_files.push_back( |
| 878 NaClResourcePrefetchResult( |
| 879 prefetched_resource_files_[i].file, |
| 880 // For the same reason as the comment below, always use an empty |
| 881 // base::FilePath for non-SFI mode. |
| 882 (uses_nonsfi_mode_ ? base::FilePath() : |
| 883 prefetched_resource_files_[i].file_path_metadata), |
| 884 prefetched_resource_files_[i].file_key)); |
| 885 } |
| 886 prefetched_resource_files_.clear(); |
| 887 |
874 base::FilePath file_path; | 888 base::FilePath file_path; |
875 if (uses_nonsfi_mode_) { | 889 if (uses_nonsfi_mode_) { |
876 // Don't retrieve the file path when using nonsfi mode; there's no | 890 // Don't retrieve the file path when using nonsfi mode; there's no |
877 // validation caching in that case, so it's unnecessary work, and would | 891 // validation caching in that case, so it's unnecessary work, and would |
878 // expose the file path to the plugin. | 892 // expose the file path to the plugin. |
879 | |
880 // Pass the pre-opened resource files to the loader. For the same reason | |
881 // as above, use an empty base::FilePath. | |
882 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { | |
883 params.prefetched_resource_files.push_back(NaClResourcePrefetchResult( | |
884 prefetched_resource_files_[i].file, | |
885 base::FilePath(), | |
886 prefetched_resource_files_[i].file_key)); | |
887 } | |
888 prefetched_resource_files_.clear(); | |
889 } else { | 893 } else { |
890 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | 894 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, |
891 nexe_token_.hi, | 895 nexe_token_.hi, |
892 &file_path)) { | 896 &file_path)) { |
893 // We have to reopen the file in the browser process; we don't want a | 897 // We have to reopen the file in the browser process; we don't want a |
894 // compromised renderer to pass an arbitrary fd that could get loaded | 898 // compromised renderer to pass an arbitrary fd that could get loaded |
895 // into the plugin process. | 899 // into the plugin process. |
896 if (base::PostTaskAndReplyWithResult( | 900 if (base::PostTaskAndReplyWithResult( |
897 content::BrowserThread::GetBlockingPool(), | 901 content::BrowserThread::GetBlockingPool(), |
898 FROM_HERE, | 902 FROM_HERE, |
899 base::Bind(OpenNaClReadExecImpl, | 903 base::Bind(OpenNaClReadExecImpl, |
900 file_path, | 904 file_path, |
901 true /* is_executable */), | 905 true /* is_executable */), |
902 base::Bind(&NaClProcessHost::StartNaClFileResolved, | 906 base::Bind(&NaClProcessHost::StartNaClFileResolved, |
903 weak_factory_.GetWeakPtr(), | 907 weak_factory_.GetWeakPtr(), |
904 params, | 908 params, |
905 file_path))) { | 909 file_path))) { |
906 return true; | 910 return true; |
907 } | 911 } |
908 } | 912 } |
909 // TODO(yusukes): Handle |prefetched_resource_files_| for SFI-NaCl. | |
910 DCHECK(prefetched_resource_files_.empty()); | |
911 } | 913 } |
912 | 914 |
913 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 915 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
914 process_->GetData().handle); | 916 process_->GetData().handle); |
915 process_->Send(new NaClProcessMsg_Start(params)); | 917 process_->Send(new NaClProcessMsg_Start(params)); |
916 return true; | 918 return true; |
917 } | 919 } |
918 | 920 |
919 void NaClProcessHost::StartNaClFileResolved( | 921 void NaClProcessHost::StartNaClFileResolved( |
920 NaClStartParams params, | 922 NaClStartParams params, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 process.Pass(), info, | 1182 process.Pass(), info, |
1181 base::MessageLoopProxy::current(), | 1183 base::MessageLoopProxy::current(), |
1182 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1184 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1183 weak_factory_.GetWeakPtr())); | 1185 weak_factory_.GetWeakPtr())); |
1184 return true; | 1186 return true; |
1185 } | 1187 } |
1186 } | 1188 } |
1187 #endif | 1189 #endif |
1188 | 1190 |
1189 } // namespace nacl | 1191 } // namespace nacl |
OLD | NEW |