| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" | 7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" |
| 8 | 8 |
| 9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
| 10 | 10 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 : plugin_(plugin), | 255 : plugin_(plugin), |
| 256 pp_instance_(pp_instance), | 256 pp_instance_(pp_instance), |
| 257 main_service_runtime_(main_service_runtime), | 257 main_service_runtime_(main_service_runtime), |
| 258 uses_nonsfi_mode_(uses_nonsfi_mode), | 258 uses_nonsfi_mode_(uses_nonsfi_mode), |
| 259 reverse_service_(NULL), | 259 reverse_service_(NULL), |
| 260 anchor_(new nacl::WeakRefAnchor()), | 260 anchor_(new nacl::WeakRefAnchor()), |
| 261 rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, | 261 rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, |
| 262 init_done_cb, crash_cb)), | 262 init_done_cb, crash_cb)), |
| 263 start_sel_ldr_done_(false), | 263 start_sel_ldr_done_(false), |
| 264 start_nexe_done_(false), | 264 start_nexe_done_(false), |
| 265 nexe_started_ok_(false) { | 265 nexe_started_ok_(false), |
| 266 bootstrap_channel_(NACL_INVALID_HANDLE) { |
| 266 NaClSrpcChannelInitialize(&command_channel_); | 267 NaClSrpcChannelInitialize(&command_channel_); |
| 267 NaClXMutexCtor(&mu_); | 268 NaClXMutexCtor(&mu_); |
| 268 NaClXCondVarCtor(&cond_); | 269 NaClXCondVarCtor(&cond_); |
| 269 } | 270 } |
| 270 | 271 |
| 271 bool ServiceRuntime::SetupCommandChannel() { | 272 bool ServiceRuntime::SetupCommandChannel() { |
| 272 NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n", | 273 NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n", |
| 273 static_cast<void*>(this), | 274 static_cast<void*>(this), |
| 274 static_cast<void*>(subprocess_.get())); | 275 static_cast<void*>(subprocess_.get())); |
| 276 // Set up the bootstrap channel in our subprocess so that we can establish |
| 277 // SRPC. |
| 278 subprocess_->set_channel(bootstrap_channel_); |
| 279 |
| 275 if (uses_nonsfi_mode_) { | 280 if (uses_nonsfi_mode_) { |
| 276 // In non-SFI mode, no SRPC is used. Just skips and returns success. | 281 // In non-SFI mode, no SRPC is used. Just skips and returns success. |
| 277 return true; | 282 return true; |
| 278 } | 283 } |
| 279 | 284 |
| 280 if (!subprocess_->SetupCommand(&command_channel_)) { | 285 if (!subprocess_->SetupCommand(&command_channel_)) { |
| 281 ErrorInfo error_info; | 286 ErrorInfo error_info; |
| 282 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, | 287 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, |
| 283 "ServiceRuntime: command channel creation failed"); | 288 "ServiceRuntime: command channel creation failed"); |
| 284 ReportLoadError(error_info); | 289 ReportLoadError(error_info); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER, | 396 PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER, |
| 392 "ServiceRuntime: failed to create sel_ldr launcher"); | 397 "ServiceRuntime: failed to create sel_ldr launcher"); |
| 393 ReportLoadError(error_info); | 398 ReportLoadError(error_info); |
| 394 pp::Module::Get()->core()->CallOnMainThread(0, callback, PP_ERROR_FAILED); | 399 pp::Module::Get()->core()->CallOnMainThread(0, callback, PP_ERROR_FAILED); |
| 395 return; | 400 return; |
| 396 } | 401 } |
| 397 | 402 |
| 398 bool enable_dev_interfaces = | 403 bool enable_dev_interfaces = |
| 399 GetNaClInterface()->DevInterfacesEnabled(pp_instance_); | 404 GetNaClInterface()->DevInterfacesEnabled(pp_instance_); |
| 400 | 405 |
| 401 tmp_subprocess->Start(pp_instance_, | 406 GetNaClInterface()->LaunchSelLdr( |
| 402 main_service_runtime_, | 407 pp_instance_, |
| 403 params.url.c_str(), | 408 PP_FromBool(main_service_runtime_), |
| 404 ¶ms.file_info, | 409 params.url.c_str(), |
| 405 params.uses_irt, | 410 ¶ms.file_info, |
| 406 params.uses_ppapi, | 411 PP_FromBool(params.uses_irt), |
| 407 uses_nonsfi_mode_, | 412 PP_FromBool(params.uses_ppapi), |
| 408 enable_dev_interfaces, | 413 PP_FromBool(uses_nonsfi_mode_), |
| 409 params.enable_dyncode_syscalls, | 414 PP_FromBool(enable_dev_interfaces), |
| 410 params.enable_exception_handling, | 415 PP_FromBool(params.enable_dyncode_syscalls), |
| 411 params.enable_crash_throttling, | 416 PP_FromBool(params.enable_exception_handling), |
| 412 callback); | 417 PP_FromBool(params.enable_crash_throttling), |
| 418 &bootstrap_channel_, |
| 419 callback.pp_completion_callback()); |
| 413 subprocess_.reset(tmp_subprocess.release()); | 420 subprocess_.reset(tmp_subprocess.release()); |
| 414 } | 421 } |
| 415 | 422 |
| 416 bool ServiceRuntime::WaitForSelLdrStart() { | 423 bool ServiceRuntime::WaitForSelLdrStart() { |
| 417 // Time to wait on condvar (for browser to create a new sel_ldr process on | 424 // Time to wait on condvar (for browser to create a new sel_ldr process on |
| 418 // our behalf). Use 6 seconds to be *fairly* conservative. | 425 // our behalf). Use 6 seconds to be *fairly* conservative. |
| 419 // | 426 // |
| 420 // On surfaway, the CallOnMainThread above may never get scheduled | 427 // On surfaway, the CallOnMainThread above may never get scheduled |
| 421 // to unblock this condvar, or the IPC reply from the browser to renderer | 428 // to unblock this condvar, or the IPC reply from the browser to renderer |
| 422 // might get canceled/dropped. However, it is currently important to | 429 // might get canceled/dropped. However, it is currently important to |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 631 |
| 625 nacl::string ServiceRuntime::GetCrashLogOutput() { | 632 nacl::string ServiceRuntime::GetCrashLogOutput() { |
| 626 if (NULL != subprocess_.get()) { | 633 if (NULL != subprocess_.get()) { |
| 627 return subprocess_->GetCrashLogOutput(); | 634 return subprocess_->GetCrashLogOutput(); |
| 628 } else { | 635 } else { |
| 629 return std::string(); | 636 return std::string(); |
| 630 } | 637 } |
| 631 } | 638 } |
| 632 | 639 |
| 633 } // namespace plugin | 640 } // namespace plugin |
| OLD | NEW |