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

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: code review Created 6 years, 1 month 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::NaClProcessHost(
239 base::File nexe_file, 239 const GURL& manifest_url,
240 const NaClFileToken& nexe_token, 240 base::File nexe_file,
241 ppapi::PpapiPermissions permissions, 241 const NaClFileToken& nexe_token,
242 int render_view_id, 242 scoped_ptr<base::File[]> resource_files,
teravest 2014/10/24 16:18:06 Maybe resource_files/resource_file_tokens/resource
Yusuke Sato 2014/11/04 22:50:21 Done.
243 uint32 permission_bits, 243 const std::vector<std::pair<uint64_t, uint64_t> >& resource_file_tokens,
244 bool uses_nonsfi_mode, 244 const std::vector<std::string>& resource_keys,
245 bool off_the_record, 245 ppapi::PpapiPermissions permissions,
246 NaClAppProcessType process_type, 246 int render_view_id,
247 const base::FilePath& profile_directory) 247 uint32 permission_bits,
248 bool uses_nonsfi_mode,
249 bool off_the_record,
250 NaClAppProcessType process_type,
251 const base::FilePath& profile_directory)
248 : manifest_url_(manifest_url), 252 : manifest_url_(manifest_url),
249 nexe_file_(nexe_file.Pass()), 253 nexe_file_(nexe_file.Pass()),
250 nexe_token_(nexe_token), 254 nexe_token_(nexe_token),
255 resource_files_(resource_files.Pass()),
256 resource_file_tokens_(resource_file_tokens),
257 resource_keys_(resource_keys),
251 permissions_(permissions), 258 permissions_(permissions),
252 #if defined(OS_WIN) 259 #if defined(OS_WIN)
253 process_launched_by_broker_(false), 260 process_launched_by_broker_(false),
254 #endif 261 #endif
255 reply_msg_(NULL), 262 reply_msg_(NULL),
256 #if defined(OS_WIN) 263 #if defined(OS_WIN)
257 debug_exception_handler_requested_(false), 264 debug_exception_handler_requested_(false),
258 #endif 265 #endif
259 uses_nonsfi_mode_(uses_nonsfi_mode), 266 uses_nonsfi_mode_(uses_nonsfi_mode),
260 enable_debug_stub_(false), 267 enable_debug_stub_(false),
261 enable_crash_throttling_(false), 268 enable_crash_throttling_(false),
262 off_the_record_(off_the_record), 269 off_the_record_(off_the_record),
263 process_type_(process_type), 270 process_type_(process_type),
264 profile_directory_(profile_directory), 271 profile_directory_(profile_directory),
265 render_view_id_(render_view_id), 272 render_view_id_(render_view_id),
266 weak_factory_(this) { 273 weak_factory_(this) {
274 CHECK(resource_file_tokens_.size() == resource_keys_.size());
267 process_.reset(content::BrowserChildProcessHost::Create( 275 process_.reset(content::BrowserChildProcessHost::Create(
268 PROCESS_TYPE_NACL_LOADER, this)); 276 PROCESS_TYPE_NACL_LOADER, this));
269 277
270 // Set the display name so the user knows what plugin the process is running. 278 // Set the display name so the user knows what plugin the process is running.
271 // We aren't on the UI thread so getting the pref locale for language 279 // We aren't on the UI thread so getting the pref locale for language
272 // formatting isn't possible, so IDN will be lost, but this is probably OK 280 // formatting isn't possible, so IDN will be lost, but this is probably OK
273 // for this use case. 281 // for this use case.
274 process_->SetName(net::FormatUrl(manifest_url_, std::string())); 282 process_->SetName(net::FormatUrl(manifest_url_, std::string()));
275 283
276 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch( 284 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 881 }
874 #endif 882 #endif
875 } 883 }
876 884
877 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, 885 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle,
878 &params.crash_info_shmem_handle)) { 886 &params.crash_info_shmem_handle)) {
879 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; 887 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer";
880 return false; 888 return false;
881 } 889 }
882 890
883 base::FilePath file_path; 891 if (uses_nonsfi_mode_) {
884 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo, 892 params.resource_keys = resource_keys_;
885 nexe_token_.hi, 893 for (size_t i = 0; i < resource_keys_.size(); ++i) {
886 &file_path)) { 894 params.resource_files.push_back(IPC::TakeFileHandleForProcess(
887 // We have to reopen the file in the browser process; we don't want a 895 resource_files_[i].Pass(), process_->GetData().handle));
888 // compromised renderer to pass an arbitrary fd that could get loaded 896 }
889 // into the plugin process. 897 } else {
890 if (base::PostTaskAndReplyWithResult( 898 // TODO(yusukes): 1) Support pre-opening resource files. 2) Validate file
891 content::BrowserThread::GetBlockingPool(), 899 // tokens for resource files.
892 FROM_HERE, 900 base::FilePath file_path;
893 base::Bind(OpenNaClReadExecImpl, 901 if (NaClBrowser::GetInstance()->GetFilePath(nexe_token_.lo,
894 file_path, 902 nexe_token_.hi,
895 true /* is_executable */), 903 &file_path)) {
896 base::Bind(&NaClProcessHost::StartNaClFileResolved, 904 // We have to reopen the file in the browser process; we don't want a
897 weak_factory_.GetWeakPtr(), 905 // compromised renderer to pass an arbitrary fd that could get loaded
898 params, 906 // into the plugin process.
899 file_path))) { 907 if (base::PostTaskAndReplyWithResult(
900 return true; 908 content::BrowserThread::GetBlockingPool(),
909 FROM_HERE,
910 base::Bind(OpenNaClReadExecImpl,
911 file_path,
912 true /* is_executable */),
913 base::Bind(&NaClProcessHost::StartNaClFileResolved,
914 weak_factory_.GetWeakPtr(),
915 params,
916 file_path))) {
917 return true;
918 }
901 } 919 }
902 } 920 }
903 921
904 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), 922 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(),
905 process_->GetData().handle); 923 process_->GetData().handle);
906 process_->Send(new NaClProcessMsg_Start(params)); 924 process_->Send(new NaClProcessMsg_Start(params));
907 return true; 925 return true;
908 } 926 }
909 927
910 void NaClProcessHost::StartNaClFileResolved( 928 void NaClProcessHost::StartNaClFileResolved(
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 process_handle.Take(), info, 1191 process_handle.Take(), info,
1174 base::MessageLoopProxy::current(), 1192 base::MessageLoopProxy::current(),
1175 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1193 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1176 weak_factory_.GetWeakPtr())); 1194 weak_factory_.GetWeakPtr()));
1177 return true; 1195 return true;
1178 } 1196 }
1179 } 1197 }
1180 #endif 1198 #endif
1181 1199
1182 } // namespace nacl 1200 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698