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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 } | 892 } |
893 #endif | 893 #endif |
894 } | 894 } |
895 | 895 |
896 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 896 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, |
897 ¶ms.crash_info_shmem_handle)) { | 897 ¶ms.crash_info_shmem_handle)) { |
898 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 898 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; |
899 return false; | 899 return false; |
900 } | 900 } |
901 | 901 |
| 902 // Pass the pre-opened resource files to the loader. We do not have to reopen |
| 903 // resource files here even for SFI mode because the descriptors are not from |
| 904 // a renderer. |
| 905 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) { |
| 906 params.prefetched_resource_files.push_back( |
| 907 NaClResourceFileInfo( |
| 908 prefetched_resource_files_info_[i].file, |
| 909 // For the same reason as the comment below, always use an empty |
| 910 // base::FilePath for non-SFI mode. |
| 911 (uses_nonsfi_mode_ ? base::FilePath() : |
| 912 prefetched_resource_files_info_[i].file_path_metadata), |
| 913 prefetched_resource_files_info_[i].file_key)); |
| 914 } |
| 915 prefetched_resource_files_info_.clear(); |
| 916 |
902 base::FilePath file_path; | 917 base::FilePath file_path; |
903 if (uses_nonsfi_mode_) { | 918 if (uses_nonsfi_mode_) { |
904 // Don't retrieve the file path when using nonsfi mode; there's no | 919 // Don't retrieve the file path when using nonsfi mode; there's no |
905 // validation caching in that case, so it's unnecessary work, and would | 920 // validation caching in that case, so it's unnecessary work, and would |
906 // expose the file path to the plugin. | 921 // expose the file path to the plugin. |
907 | |
908 // Pass the pre-opened resource files to the loader. For the same reason | |
909 // as above, use an empty base::FilePath. | |
910 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) { | |
911 params.prefetched_resource_files.push_back( | |
912 NaClResourceFileInfo(prefetched_resource_files_info_[i].file, | |
913 base::FilePath(), | |
914 prefetched_resource_files_info_[i].file_key)); | |
915 } | |
916 prefetched_resource_files_info_.clear(); | |
917 } else { | 922 } else { |
918 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, | 923 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, |
919 nexe_token_.hi, | 924 nexe_token_.hi, |
920 &file_path)) { | 925 &file_path)) { |
921 // We have to reopen the file in the browser process; we don't want a | 926 // We have to reopen the file in the browser process; we don't want a |
922 // compromised renderer to pass an arbitrary fd that could get loaded | 927 // compromised renderer to pass an arbitrary fd that could get loaded |
923 // into the plugin process. | 928 // into the plugin process. |
924 if (base::PostTaskAndReplyWithResult( | 929 if (base::PostTaskAndReplyWithResult( |
925 content::BrowserThread::GetBlockingPool(), | 930 content::BrowserThread::GetBlockingPool(), |
926 FROM_HERE, | 931 FROM_HERE, |
927 base::Bind(OpenNaClReadExecImpl, | 932 base::Bind(OpenNaClReadExecImpl, |
928 file_path, | 933 file_path, |
929 true /* is_executable */), | 934 true /* is_executable */), |
930 base::Bind(&NaClProcessHost::StartNaClFileResolved, | 935 base::Bind(&NaClProcessHost::StartNaClFileResolved, |
931 weak_factory_.GetWeakPtr(), | 936 weak_factory_.GetWeakPtr(), |
932 params, | 937 params, |
933 file_path))) { | 938 file_path))) { |
934 return true; | 939 return true; |
935 } | 940 } |
936 } | 941 } |
937 // TODO(yusukes): Handle |prefetched_resource_files_info_| for SFI-NaCl. | |
938 DCHECK(prefetched_resource_files_info_.empty()); | |
939 } | 942 } |
940 | 943 |
941 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 944 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
942 process_->GetData().handle); | 945 process_->GetData().handle); |
943 process_->Send(new NaClProcessMsg_Start(params)); | 946 process_->Send(new NaClProcessMsg_Start(params)); |
944 return true; | 947 return true; |
945 } | 948 } |
946 | 949 |
947 void NaClProcessHost::StartNaClFileResolved( | 950 void NaClProcessHost::StartNaClFileResolved( |
948 NaClStartParams params, | 951 NaClStartParams params, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 process.Pass(), info, | 1211 process.Pass(), info, |
1209 base::MessageLoopProxy::current(), | 1212 base::MessageLoopProxy::current(), |
1210 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1213 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1211 weak_factory_.GetWeakPtr())); | 1214 weak_factory_.GetWeakPtr())); |
1212 return true; | 1215 return true; |
1213 } | 1216 } |
1214 } | 1217 } |
1215 #endif | 1218 #endif |
1216 | 1219 |
1217 } // namespace nacl | 1220 } // namespace nacl |
OLD | NEW |