Chromium Code Reviews| 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 "native_client/src/trusted/plugin/service_runtime.h" | 9 #include "native_client/src/trusted/plugin/service_runtime.h" |
| 10 | 10 |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 PLUGIN_PRINTF(("ServiceRuntime: got 0x%"NACL_PRIxPTR"\n", | 581 PLUGIN_PRINTF(("ServiceRuntime: got 0x%"NACL_PRIxPTR"\n", |
| 582 (uintptr_t) out_conn_cap)); | 582 (uintptr_t) out_conn_cap)); |
| 583 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( | 583 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( |
| 584 out_conn_cap); | 584 out_conn_cap); |
| 585 if (conn_cap == NULL) { | 585 if (conn_cap == NULL) { |
| 586 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_WRAPPER, | 586 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_WRAPPER, |
| 587 "ServiceRuntime: wrapper allocation failure"); | 587 "ServiceRuntime: wrapper allocation failure"); |
| 588 return false; | 588 return false; |
| 589 } | 589 } |
| 590 out_conn_cap = NULL; // ownership passed | 590 out_conn_cap = NULL; // ownership passed |
| 591 PLUGIN_PRINTF(("ServiceRuntime::InitCommunication" | |
| 592 " starting reverse service\n")); | |
| 591 reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref()); | 593 reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref()); |
| 592 if (!reverse_service_->Start()) { | 594 if (!reverse_service_->Start()) { |
| 593 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE, | 595 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE, |
| 594 "ServiceRuntime: starting reverse services failed"); | 596 "ServiceRuntime: starting reverse services failed"); |
| 595 return false; | 597 return false; |
| 596 } | 598 } |
| 597 | 599 |
| 598 // start the module. otherwise we cannot connect for multimedia | 600 // start the module. otherwise we cannot connect for multimedia |
| 599 // subsystem since that is handled by user-level code (not secure!) | 601 // subsystem since that is handled by user-level code (not secure!) |
| 600 // in libsrpc. | 602 // in libsrpc. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 617 if (LOAD_OK != load_status) { | 619 if (LOAD_OK != load_status) { |
| 618 error_info->SetReport( | 620 error_info->SetReport( |
| 619 ERROR_SEL_LDR_START_STATUS, | 621 ERROR_SEL_LDR_START_STATUS, |
| 620 NaClErrorString(static_cast<NaClErrorCode>(load_status))); | 622 NaClErrorString(static_cast<NaClErrorCode>(load_status))); |
| 621 return false; | 623 return false; |
| 622 } | 624 } |
| 623 return true; | 625 return true; |
| 624 } | 626 } |
| 625 | 627 |
| 626 bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc, | 628 bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc, |
| 627 ErrorInfo* error_info, const nacl::string& url) { | 629 ErrorInfo* error_info, const nacl::string& url, |
| 630 pp::CompletionCallback crash_cb) { | |
| 628 PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n", | 631 PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n", |
| 629 reinterpret_cast<void*>(nacl_desc))); | 632 reinterpret_cast<void*>(nacl_desc))); |
| 630 | 633 |
| 631 #ifdef NACL_STANDALONE | 634 #ifdef NACL_STANDALONE |
| 632 nacl::scoped_ptr<nacl::SelLdrLauncherStandalone> | 635 nacl::scoped_ptr<nacl::SelLdrLauncherStandalone> |
| 633 tmp_subprocess(new nacl::SelLdrLauncherStandalone()); | 636 tmp_subprocess(new nacl::SelLdrLauncherStandalone()); |
| 634 #else | 637 #else |
| 635 nacl::scoped_ptr<SelLdrLauncherChrome> | 638 nacl::scoped_ptr<SelLdrLauncherChrome> |
| 636 tmp_subprocess(new SelLdrLauncherChrome()); | 639 tmp_subprocess(new SelLdrLauncherChrome()); |
| 637 #endif | 640 #endif |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 648 #endif | 651 #endif |
| 649 if (!started) { | 652 if (!started) { |
| 650 PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n")); | 653 PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n")); |
| 651 error_info->SetReport(ERROR_SEL_LDR_LAUNCH, | 654 error_info->SetReport(ERROR_SEL_LDR_LAUNCH, |
| 652 "ServiceRuntime: failed to start"); | 655 "ServiceRuntime: failed to start"); |
| 653 return false; | 656 return false; |
| 654 } | 657 } |
| 655 | 658 |
| 656 subprocess_.reset(tmp_subprocess.release()); | 659 subprocess_.reset(tmp_subprocess.release()); |
| 657 if (!InitCommunication(nacl_desc, error_info)) { | 660 if (!InitCommunication(nacl_desc, error_info)) { |
| 658 subprocess_.reset(NULL); | 661 // The subprocess_ member variable is needed to collect crash log |
| 662 // output after the error is reported. We induce a service | |
| 663 // runtime crash here, since on a load failure the service runtime | |
| 664 // does not crash itself to avoid the race where the | |
| 665 // no-more-senders error on the reverse channel service thread | |
| 666 // might cause the crash-detection logic to kick in before the | |
| 667 // start_module RPC reply has been received. | |
|
bbudge
2012/07/25 20:42:27
This comment is hard for me to understand. How abo
bsy
2012/07/25 22:07:23
Done.
| |
| 668 Log(LOG_FATAL, "reap logs"); | |
| 669 if (NULL == reverse_service_) { | |
| 670 // No crash detector thread. | |
| 671 PLUGIN_PRINTF(("scheduling to get crash log\n")); | |
| 672 pp::Module::Get()->core()->CallOnMainThread(0, crash_cb, PP_OK); | |
| 673 PLUGIN_PRINTF(("should fire soon\n")); | |
| 674 } else { | |
| 675 PLUGIN_PRINTF(("Reverse service thread will pick up crash log\n")); | |
| 676 } | |
| 659 return false; | 677 return false; |
| 660 } | 678 } |
| 661 | 679 |
| 662 PLUGIN_PRINTF(("ServiceRuntime::Start (return 1)\n")); | 680 PLUGIN_PRINTF(("ServiceRuntime::Start (return 1)\n")); |
| 663 return true; | 681 return true; |
| 664 } | 682 } |
| 665 | 683 |
| 666 SrpcClient* ServiceRuntime::SetupAppChannel() { | 684 SrpcClient* ServiceRuntime::SetupAppChannel() { |
| 667 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", | 685 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", |
| 668 reinterpret_cast<void*>(subprocess_.get()))); | 686 reinterpret_cast<void*>(subprocess_.get()))); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 | 762 |
| 745 nacl::string ServiceRuntime::GetCrashLogOutput() { | 763 nacl::string ServiceRuntime::GetCrashLogOutput() { |
| 746 if (NULL != subprocess_.get()) { | 764 if (NULL != subprocess_.get()) { |
| 747 return subprocess_->GetCrashLogOutput(); | 765 return subprocess_->GetCrashLogOutput(); |
| 748 } else { | 766 } else { |
| 749 return ""; | 767 return ""; |
| 750 } | 768 } |
| 751 } | 769 } |
| 752 | 770 |
| 753 } // namespace plugin | 771 } // namespace plugin |
| OLD | NEW |