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