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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 NaClLog(4, "PluginReverseInterface::AddTempQuotaManagedFile: " | 444 NaClLog(4, "PluginReverseInterface::AddTempQuotaManagedFile: " |
445 "(file_id='%s')\n", file_id.c_str()); | 445 "(file_id='%s')\n", file_id.c_str()); |
446 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); | 446 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); |
447 nacl::MutexLocker take(&mu_); | 447 nacl::MutexLocker take(&mu_); |
448 quota_files_.insert(file_key); | 448 quota_files_.insert(file_key); |
449 } | 449 } |
450 | 450 |
451 ServiceRuntime::ServiceRuntime(Plugin* plugin, | 451 ServiceRuntime::ServiceRuntime(Plugin* plugin, |
452 const Manifest* manifest, | 452 const Manifest* manifest, |
453 bool main_service_runtime, | 453 bool main_service_runtime, |
454 bool nonsfi_enabled, | |
454 pp::CompletionCallback init_done_cb, | 455 pp::CompletionCallback init_done_cb, |
455 pp::CompletionCallback crash_cb) | 456 pp::CompletionCallback crash_cb) |
456 : plugin_(plugin), | 457 : plugin_(plugin), |
457 main_service_runtime_(main_service_runtime), | 458 main_service_runtime_(main_service_runtime), |
459 nonsfi_enabled_(nonsfi_enabled), | |
458 reverse_service_(NULL), | 460 reverse_service_(NULL), |
459 anchor_(new nacl::WeakRefAnchor()), | 461 anchor_(new nacl::WeakRefAnchor()), |
460 rev_interface_(new PluginReverseInterface(anchor_, plugin, | 462 rev_interface_(new PluginReverseInterface(anchor_, plugin, |
461 manifest, | 463 manifest, |
462 this, | 464 this, |
463 init_done_cb, crash_cb)), | 465 init_done_cb, crash_cb)), |
464 exit_status_(-1), | 466 exit_status_(-1), |
465 start_sel_ldr_done_(false), | 467 start_sel_ldr_done_(false), |
466 callback_factory_(this) { | 468 callback_factory_(this) { |
467 NaClSrpcChannelInitialize(&command_channel_); | 469 NaClSrpcChannelInitialize(&command_channel_); |
(...skipping 17 matching lines...) Expand all Loading... | |
485 | 487 |
486 if (!subprocess_->LoadModule(&command_channel_, nacl_desc)) { | 488 if (!subprocess_->LoadModule(&command_channel_, nacl_desc)) { |
487 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, | 489 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, |
488 "ServiceRuntime: load module failed"); | 490 "ServiceRuntime: load module failed"); |
489 return false; | 491 return false; |
490 } | 492 } |
491 return true; | 493 return true; |
492 } | 494 } |
493 | 495 |
494 bool ServiceRuntime::InitReverseService(ErrorInfo* error_info) { | 496 bool ServiceRuntime::InitReverseService(ErrorInfo* error_info) { |
497 if (nonsfi_enabled_) { | |
498 // In non-SFI mode, open_resource() has not yet been supported, so we | |
Mark Seaborn
2014/02/27 17:10:22
"is not yet supported"
hidehiko
2014/02/28 06:41:54
Done.
| |
499 // do not need the reverse service. So, skip the initialization (with | |
500 // calling the completion callback). | |
501 // Note that there is on going work to replace SRPC by Chrome IPC (not only | |
Mark Seaborn
2014/02/27 17:10:22
You might link to the issue here...
hidehiko
2014/02/28 06:41:54
Done.
| |
502 // for non-SFI mode, but also for SFI mode), and non-SFI mode will use | |
503 // Chrome IPC for open_resource() after the refacrogin is done. | |
Mark Seaborn
2014/02/27 17:10:22
"refactoring"
hidehiko
2014/02/28 06:41:54
Oops. Done.
| |
504 rev_interface_->StartupInitializationComplete(); | |
505 return true; | |
506 } | |
507 | |
495 // Hook up the reverse service channel. We are the IMC client, but | 508 // Hook up the reverse service channel. We are the IMC client, but |
496 // provide SRPC service. | 509 // provide SRPC service. |
497 NaClDesc* out_conn_cap; | 510 NaClDesc* out_conn_cap; |
498 NaClSrpcResultCodes rpc_result = | 511 NaClSrpcResultCodes rpc_result = |
499 NaClSrpcInvokeBySignature(&command_channel_, | 512 NaClSrpcInvokeBySignature(&command_channel_, |
500 "reverse_setup::h", | 513 "reverse_setup::h", |
501 &out_conn_cap); | 514 &out_conn_cap); |
502 | 515 |
503 if (NACL_SRPC_RESULT_OK != rpc_result) { | 516 if (NACL_SRPC_RESULT_OK != rpc_result) { |
504 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, | 517 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, |
(...skipping 20 matching lines...) Expand all Loading... | |
525 return false; | 538 return false; |
526 } | 539 } |
527 return true; | 540 return true; |
528 } | 541 } |
529 | 542 |
530 bool ServiceRuntime::StartModule(ErrorInfo* error_info) { | 543 bool ServiceRuntime::StartModule(ErrorInfo* error_info) { |
531 // start the module. otherwise we cannot connect for multimedia | 544 // start the module. otherwise we cannot connect for multimedia |
532 // subsystem since that is handled by user-level code (not secure!) | 545 // subsystem since that is handled by user-level code (not secure!) |
533 // in libsrpc. | 546 // in libsrpc. |
534 int load_status = -1; | 547 int load_status = -1; |
535 NaClSrpcResultCodes rpc_result = | 548 if (nonsfi_enabled_) { |
536 NaClSrpcInvokeBySignature(&command_channel_, | 549 // In non-SFI mode, we don't need to call start_module SRPC to launch |
537 "start_module::i", | 550 // the plugin. |
538 &load_status); | 551 load_status = LOAD_OK; |
552 } else { | |
553 NaClSrpcResultCodes rpc_result = | |
554 NaClSrpcInvokeBySignature(&command_channel_, | |
555 "start_module::i", | |
556 &load_status); | |
539 | 557 |
540 if (NACL_SRPC_RESULT_OK != rpc_result) { | 558 if (NACL_SRPC_RESULT_OK != rpc_result) { |
541 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_START_MODULE, | 559 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_START_MODULE, |
542 "ServiceRuntime: could not start nacl module"); | 560 "ServiceRuntime: could not start nacl module"); |
543 return false; | 561 return false; |
562 } | |
544 } | 563 } |
545 NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", | 564 |
546 load_status); | 565 NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", load_status); |
547 if (main_service_runtime_) { | 566 if (main_service_runtime_) { |
548 plugin_->ReportSelLdrLoadStatus(load_status); | 567 plugin_->ReportSelLdrLoadStatus(load_status); |
549 } | 568 } |
550 if (LOAD_OK != load_status) { | 569 if (LOAD_OK != load_status) { |
551 error_info->SetReport( | 570 error_info->SetReport( |
552 PP_NACL_ERROR_SEL_LDR_START_STATUS, | 571 PP_NACL_ERROR_SEL_LDR_START_STATUS, |
553 NaClErrorString(static_cast<NaClErrorCode>(load_status))); | 572 NaClErrorString(static_cast<NaClErrorCode>(load_status))); |
554 return false; | 573 return false; |
555 } | 574 } |
556 return true; | 575 return true; |
(...skipping 22 matching lines...) Expand all Loading... | |
579 callback); | 598 callback); |
580 | 599 |
581 tmp_subprocess->Start(plugin_->pp_instance(), | 600 tmp_subprocess->Start(plugin_->pp_instance(), |
582 params.url.c_str(), | 601 params.url.c_str(), |
583 params.uses_irt, | 602 params.uses_irt, |
584 params.uses_ppapi, | 603 params.uses_ppapi, |
585 params.enable_dev_interfaces, | 604 params.enable_dev_interfaces, |
586 params.enable_dyncode_syscalls, | 605 params.enable_dyncode_syscalls, |
587 params.enable_exception_handling, | 606 params.enable_exception_handling, |
588 params.enable_crash_throttling, | 607 params.enable_crash_throttling, |
608 params.enable_nonsfi, | |
589 &start_sel_ldr_error_message_, | 609 &start_sel_ldr_error_message_, |
590 internal_callback); | 610 internal_callback); |
591 subprocess_.reset(tmp_subprocess.release()); | 611 subprocess_.reset(tmp_subprocess.release()); |
592 } | 612 } |
593 | 613 |
594 void ServiceRuntime::StartSelLdrContinuation(int32_t pp_error, | 614 void ServiceRuntime::StartSelLdrContinuation(int32_t pp_error, |
595 pp::CompletionCallback callback) { | 615 pp::CompletionCallback callback) { |
596 if (pp_error != PP_OK) { | 616 if (pp_error != PP_OK) { |
597 NaClLog(LOG_ERROR, "ServiceRuntime::StartSelLdrContinuation " | 617 NaClLog(LOG_ERROR, "ServiceRuntime::StartSelLdrContinuation " |
598 " (start failed)\n"); | 618 " (start failed)\n"); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 | 759 |
740 nacl::string ServiceRuntime::GetCrashLogOutput() { | 760 nacl::string ServiceRuntime::GetCrashLogOutput() { |
741 if (NULL != subprocess_.get()) { | 761 if (NULL != subprocess_.get()) { |
742 return subprocess_->GetCrashLogOutput(); | 762 return subprocess_->GetCrashLogOutput(); |
743 } else { | 763 } else { |
744 return std::string(); | 764 return std::string(); |
745 } | 765 } |
746 } | 766 } |
747 | 767 |
748 } // namespace plugin | 768 } // namespace plugin |
OLD | NEW |