Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 649603004: Non-SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 void CloseFile(base::File file) { 228 void CloseFile(base::File file) {
229 // The base::File destructor will close the file for us. 229 // The base::File destructor will close the file for us.
230 } 230 }
231 231
232 } // namespace 232 } // namespace
233 233
234 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ = 234 unsigned NaClProcessHost::keepalive_throttle_interval_milliseconds_ =
235 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds; 235 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds;
236 236
237 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, 237 NaClProcessHost::NaClProcessHost(
238 base::File nexe_file, 238 const GURL& manifest_url,
239 const NaClFileToken& nexe_token, 239 base::File nexe_file,
240 ppapi::PpapiPermissions permissions, 240 const NaClFileToken& nexe_token,
241 int render_view_id, 241 const std::vector<
242 uint32 permission_bits, 242 nacl::NaClResourceFileInfo>& prefetched_resource_files_info,
243 bool uses_nonsfi_mode, 243 ppapi::PpapiPermissions permissions,
244 bool off_the_record, 244 int render_view_id,
245 NaClAppProcessType process_type, 245 uint32 permission_bits,
246 const base::FilePath& profile_directory) 246 bool uses_nonsfi_mode,
247 bool off_the_record,
248 NaClAppProcessType process_type,
249 const base::FilePath& profile_directory)
247 : manifest_url_(manifest_url), 250 : manifest_url_(manifest_url),
248 nexe_file_(nexe_file.Pass()), 251 nexe_file_(nexe_file.Pass()),
249 nexe_token_(nexe_token), 252 nexe_token_(nexe_token),
253 prefetched_resource_files_info_(prefetched_resource_files_info),
250 permissions_(permissions), 254 permissions_(permissions),
251 #if defined(OS_WIN) 255 #if defined(OS_WIN)
252 process_launched_by_broker_(false), 256 process_launched_by_broker_(false),
253 #endif 257 #endif
254 reply_msg_(NULL), 258 reply_msg_(NULL),
255 #if defined(OS_WIN) 259 #if defined(OS_WIN)
256 debug_exception_handler_requested_(false), 260 debug_exception_handler_requested_(false),
257 #endif 261 #endif
258 uses_nonsfi_mode_(uses_nonsfi_mode), 262 uses_nonsfi_mode_(uses_nonsfi_mode),
259 enable_debug_stub_(false), 263 enable_debug_stub_(false),
(...skipping 27 matching lines...) Expand all
287 base::StringPrintf("NaCl process exited with status %i (0x%x)", 291 base::StringPrintf("NaCl process exited with status %i (0x%x)",
288 exit_code, exit_code); 292 exit_code, exit_code);
289 if (exit_code == 0) { 293 if (exit_code == 0) {
290 VLOG(1) << message; 294 VLOG(1) << message;
291 } else { 295 } else {
292 LOG(ERROR) << message; 296 LOG(ERROR) << message;
293 } 297 }
294 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id); 298 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id);
295 } 299 }
296 300
301 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) {
302 // The process failed to launch for some reason. Close resource file
303 // handles.
304 base::File file(IPC::PlatformFileForTransitToFile(
305 prefetched_resource_files_info_[i].file));
306 content::BrowserThread::GetBlockingPool()->PostTask(
307 FROM_HERE,
308 base::Bind(&CloseFile, base::Passed(file.Pass())));
309 }
310
297 if (reply_msg_) { 311 if (reply_msg_) {
298 // The process failed to launch for some reason. 312 // The process failed to launch for some reason.
299 // Don't keep the renderer hanging. 313 // Don't keep the renderer hanging.
300 reply_msg_->set_reply_error(); 314 reply_msg_->set_reply_error();
301 nacl_host_message_filter_->Send(reply_msg_); 315 nacl_host_message_filter_->Send(reply_msg_);
302 } 316 }
303 #if defined(OS_WIN) 317 #if defined(OS_WIN)
304 if (process_launched_by_broker_) { 318 if (process_launched_by_broker_) {
305 NaClBrokerService::GetInstance()->OnLoaderDied(); 319 NaClBrokerService::GetInstance()->OnLoaderDied();
306 } 320 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 #endif 892 #endif
879 } 893 }
880 894
881 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, 895 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle,
882 &params.crash_info_shmem_handle)) { 896 &params.crash_info_shmem_handle)) {
883 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; 897 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer";
884 return false; 898 return false;
885 } 899 }
886 900
887 base::FilePath file_path; 901 base::FilePath file_path;
888 // Don't retrieve the file path when using nonsfi mode; there's no validation 902 if (uses_nonsfi_mode_) {
889 // caching in that case, so it's unnecessary work, and would expose the file 903 // Don't retrieve the file path when using nonsfi mode; there's no
890 // path to the plugin. 904 // validation caching in that case, so it's unnecessary work, and would
891 if (!uses_nonsfi_mode_ && 905 // expose the file path to the plugin.
892 NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, 906
893 nexe_token_.hi, 907 // Pass the pre-opened resource files to the loader. For the same reason
894 &file_path)) { 908 // as above, use an empty base::FilePath.
895 // We have to reopen the file in the browser process; we don't want a 909 for (size_t i = 0; i < prefetched_resource_files_info_.size(); ++i) {
896 // compromised renderer to pass an arbitrary fd that could get loaded 910 params.prefetched_resource_files.push_back(
897 // into the plugin process. 911 NaClResourceFileInfo(prefetched_resource_files_info_[i].file,
898 if (base::PostTaskAndReplyWithResult( 912 base::FilePath(),
899 content::BrowserThread::GetBlockingPool(), 913 prefetched_resource_files_info_[i].file_key));
900 FROM_HERE,
901 base::Bind(OpenNaClReadExecImpl,
902 file_path,
903 true /* is_executable */),
904 base::Bind(&NaClProcessHost::StartNaClFileResolved,
905 weak_factory_.GetWeakPtr(),
906 params,
907 file_path))) {
908 return true;
909 } 914 }
915 prefetched_resource_files_info_.clear();
916 } else {
917 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo,
918 nexe_token_.hi,
919 &file_path)) {
920 // 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
922 // into the plugin process.
923 if (base::PostTaskAndReplyWithResult(
924 content::BrowserThread::GetBlockingPool(),
925 FROM_HERE,
926 base::Bind(OpenNaClReadExecImpl,
927 file_path,
928 true /* is_executable */),
929 base::Bind(&NaClProcessHost::StartNaClFileResolved,
930 weak_factory_.GetWeakPtr(),
931 params,
932 file_path))) {
933 return true;
934 }
935 }
936 // TODO(yusukes): Handle |prefetched_resource_files_info_| for SFI-NaCl.
937 DCHECK(prefetched_resource_files_info_.empty());
910 } 938 }
911 939
912 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), 940 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(),
913 process_->GetData().handle); 941 process_->GetData().handle);
914 process_->Send(new NaClProcessMsg_Start(params)); 942 process_->Send(new NaClProcessMsg_Start(params));
915 return true; 943 return true;
916 } 944 }
917 945
918 void NaClProcessHost::StartNaClFileResolved( 946 void NaClProcessHost::StartNaClFileResolved(
919 NaClStartParams params, 947 NaClStartParams params,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 process.Pass(), info, 1207 process.Pass(), info,
1180 base::MessageLoopProxy::current(), 1208 base::MessageLoopProxy::current(),
1181 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1209 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1182 weak_factory_.GetWeakPtr())); 1210 weak_factory_.GetWeakPtr()));
1183 return true; 1211 return true;
1184 } 1212 }
1185 } 1213 }
1186 #endif 1214 #endif
1187 1215
1188 } // namespace nacl 1216 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698