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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 pp::CompletionCallback crash_cb) | 477 pp::CompletionCallback crash_cb) |
478 : plugin_(plugin), | 478 : plugin_(plugin), |
479 main_service_runtime_(main_service_runtime), | 479 main_service_runtime_(main_service_runtime), |
480 reverse_service_(NULL), | 480 reverse_service_(NULL), |
481 anchor_(new nacl::WeakRefAnchor()), | 481 anchor_(new nacl::WeakRefAnchor()), |
482 rev_interface_(new PluginReverseInterface(anchor_, plugin, | 482 rev_interface_(new PluginReverseInterface(anchor_, plugin, |
483 manifest, | 483 manifest, |
484 this, | 484 this, |
485 init_done_cb, crash_cb)), | 485 init_done_cb, crash_cb)), |
486 exit_status_(-1), | 486 exit_status_(-1), |
487 start_sel_ldr_done_(false) { | 487 start_sel_ldr_done_(false), |
| 488 callback_factory_(this) { |
488 NaClSrpcChannelInitialize(&command_channel_); | 489 NaClSrpcChannelInitialize(&command_channel_); |
489 NaClXMutexCtor(&mu_); | 490 NaClXMutexCtor(&mu_); |
490 NaClXCondVarCtor(&cond_); | 491 NaClXCondVarCtor(&cond_); |
491 } | 492 } |
492 | 493 |
493 bool ServiceRuntime::LoadModule(nacl::DescWrapper* nacl_desc, | 494 bool ServiceRuntime::LoadModule(nacl::DescWrapper* nacl_desc, |
494 ErrorInfo* error_info) { | 495 ErrorInfo* error_info) { |
495 NaClLog(4, "ServiceRuntime::LoadModule" | 496 NaClLog(4, "ServiceRuntime::LoadModule" |
496 " (this=%p, subprocess=%p)\n", | 497 " (this=%p, subprocess=%p)\n", |
497 static_cast<void*>(this), | 498 static_cast<void*>(this), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 571 } |
571 if (LOAD_OK != load_status) { | 572 if (LOAD_OK != load_status) { |
572 error_info->SetReport( | 573 error_info->SetReport( |
573 ERROR_SEL_LDR_START_STATUS, | 574 ERROR_SEL_LDR_START_STATUS, |
574 NaClErrorString(static_cast<NaClErrorCode>(load_status))); | 575 NaClErrorString(static_cast<NaClErrorCode>(load_status))); |
575 return false; | 576 return false; |
576 } | 577 } |
577 return true; | 578 return true; |
578 } | 579 } |
579 | 580 |
580 bool ServiceRuntime::StartSelLdr(const SelLdrStartParams& params) { | 581 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, |
| 582 pp::CompletionCallback callback) { |
581 NaClLog(4, "ServiceRuntime::Start\n"); | 583 NaClLog(4, "ServiceRuntime::Start\n"); |
582 | 584 |
583 nacl::scoped_ptr<SelLdrLauncherChrome> | 585 nacl::scoped_ptr<SelLdrLauncherChrome> |
584 tmp_subprocess(new SelLdrLauncherChrome()); | 586 tmp_subprocess(new SelLdrLauncherChrome()); |
585 if (NULL == tmp_subprocess.get()) { | 587 if (NULL == tmp_subprocess.get()) { |
586 NaClLog(LOG_ERROR, "ServiceRuntime::Start (subprocess create failed)\n"); | 588 NaClLog(LOG_ERROR, "ServiceRuntime::Start (subprocess create failed)\n"); |
587 if (main_service_runtime_) { | 589 if (main_service_runtime_) { |
588 ErrorInfo error_info; | 590 ErrorInfo error_info; |
589 error_info.SetReport( | 591 error_info.SetReport( |
590 ERROR_SEL_LDR_CREATE_LAUNCHER, | 592 ERROR_SEL_LDR_CREATE_LAUNCHER, |
591 "ServiceRuntime: failed to create sel_ldr launcher"); | 593 "ServiceRuntime: failed to create sel_ldr launcher"); |
592 plugin_->ReportLoadError(error_info); | 594 plugin_->ReportLoadError(error_info); |
593 } | 595 } |
594 return false; | 596 pp::Module::Get()->core()->CallOnMainThread(0, callback, PP_ERROR_FAILED); |
| 597 return; |
595 } | 598 } |
596 nacl::string error_message; | 599 pp::CompletionCallback internal_callback = |
597 bool started = tmp_subprocess->Start(plugin_->pp_instance(), | 600 callback_factory_.NewCallback(&ServiceRuntime::StartSelLdrContinuation, |
598 params.url.c_str(), | 601 callback); |
599 params.uses_irt, | 602 |
600 params.uses_ppapi, | 603 tmp_subprocess->Start(plugin_->pp_instance(), |
601 params.enable_dev_interfaces, | 604 params.url.c_str(), |
602 params.enable_dyncode_syscalls, | 605 params.uses_irt, |
603 params.enable_exception_handling, | 606 params.uses_ppapi, |
604 params.enable_crash_throttling, | 607 params.enable_dev_interfaces, |
605 &error_message); | 608 params.enable_dyncode_syscalls, |
606 if (!started) { | 609 params.enable_exception_handling, |
607 NaClLog(LOG_ERROR, "ServiceRuntime::Start (start failed)\n"); | 610 params.enable_crash_throttling, |
| 611 &start_sel_ldr_error_message_, |
| 612 internal_callback); |
| 613 subprocess_.reset(tmp_subprocess.release()); |
| 614 } |
| 615 |
| 616 void ServiceRuntime::StartSelLdrContinuation(int32_t pp_error, |
| 617 pp::CompletionCallback callback) { |
| 618 if (pp_error != PP_OK) { |
| 619 NaClLog(LOG_ERROR, "ServiceRuntime::StartSelLdrContinuation " |
| 620 " (start failed)\n"); |
608 if (main_service_runtime_) { | 621 if (main_service_runtime_) { |
| 622 std::string error_message; |
| 623 pp::Var var_error_message_cpp(pp::PASS_REF, start_sel_ldr_error_message_); |
| 624 if (var_error_message_cpp.is_string()) { |
| 625 error_message = var_error_message_cpp.AsString(); |
| 626 } |
609 ErrorInfo error_info; | 627 ErrorInfo error_info; |
610 error_info.SetReportWithConsoleOnlyError( | 628 error_info.SetReportWithConsoleOnlyError( |
611 ERROR_SEL_LDR_LAUNCH, | 629 ERROR_SEL_LDR_LAUNCH, |
612 "ServiceRuntime: failed to start", | 630 "ServiceRuntime: failed to start", |
613 error_message); | 631 error_message); |
614 plugin_->ReportLoadError(error_info); | 632 plugin_->ReportLoadError(error_info); |
615 } | 633 } |
616 return false; | |
617 } | 634 } |
618 | 635 pp::Module::Get()->core()->CallOnMainThread(0, callback, pp_error); |
619 subprocess_.reset(tmp_subprocess.release()); | |
620 NaClLog(4, "ServiceRuntime::StartSelLdr (return 1)\n"); | |
621 return true; | |
622 } | 636 } |
623 | 637 |
624 void ServiceRuntime::WaitForSelLdrStart() { | 638 void ServiceRuntime::WaitForSelLdrStart() { |
625 nacl::MutexLocker take(&mu_); | 639 nacl::MutexLocker take(&mu_); |
626 while(!start_sel_ldr_done_) { | 640 while(!start_sel_ldr_done_) { |
627 NaClXCondVarWait(&cond_, &mu_); | 641 NaClXCondVarWait(&cond_, &mu_); |
628 } | 642 } |
629 } | 643 } |
630 | 644 |
631 void ServiceRuntime::SignalStartSelLdrDone() { | 645 void ServiceRuntime::SignalStartSelLdrDone() { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 761 |
748 nacl::string ServiceRuntime::GetCrashLogOutput() { | 762 nacl::string ServiceRuntime::GetCrashLogOutput() { |
749 if (NULL != subprocess_.get()) { | 763 if (NULL != subprocess_.get()) { |
750 return subprocess_->GetCrashLogOutput(); | 764 return subprocess_->GetCrashLogOutput(); |
751 } else { | 765 } else { |
752 return std::string(); | 766 return std::string(); |
753 } | 767 } |
754 } | 768 } |
755 | 769 |
756 } // namespace plugin | 770 } // namespace plugin |
OLD | NEW |