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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/service_runtime.cc

Issue 177113009: Support non-SFI mode in NaCl manifest file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months 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 /* 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
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 uses_nonsfi_mode,
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 uses_nonsfi_mode_(uses_nonsfi_mode),
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
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 (uses_nonsfi_mode_) {
498 // In non-SFI mode, open_resource() is not yet supported, so we do not
499 // need the reverse service. So, skip the initialization (with calling
500 // the completion callback).
501 // Note that there is on going work to replace SRPC by Chrome IPC (not only
502 // for non-SFI mode, but also for SFI mode) (crbug.com/333950),
503 // and non-SFI mode will use Chrome IPC for open_resource() after the
504 // refactoring is done.
505 rev_interface_->StartupInitializationComplete();
506 return true;
507 }
508
495 // Hook up the reverse service channel. We are the IMC client, but 509 // Hook up the reverse service channel. We are the IMC client, but
496 // provide SRPC service. 510 // provide SRPC service.
497 NaClDesc* out_conn_cap; 511 NaClDesc* out_conn_cap;
498 NaClSrpcResultCodes rpc_result = 512 NaClSrpcResultCodes rpc_result =
499 NaClSrpcInvokeBySignature(&command_channel_, 513 NaClSrpcInvokeBySignature(&command_channel_,
500 "reverse_setup::h", 514 "reverse_setup::h",
501 &out_conn_cap); 515 &out_conn_cap);
502 516
503 if (NACL_SRPC_RESULT_OK != rpc_result) { 517 if (NACL_SRPC_RESULT_OK != rpc_result) {
504 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, 518 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP,
(...skipping 20 matching lines...) Expand all
525 return false; 539 return false;
526 } 540 }
527 return true; 541 return true;
528 } 542 }
529 543
530 bool ServiceRuntime::StartModule(ErrorInfo* error_info) { 544 bool ServiceRuntime::StartModule(ErrorInfo* error_info) {
531 // start the module. otherwise we cannot connect for multimedia 545 // start the module. otherwise we cannot connect for multimedia
532 // subsystem since that is handled by user-level code (not secure!) 546 // subsystem since that is handled by user-level code (not secure!)
533 // in libsrpc. 547 // in libsrpc.
534 int load_status = -1; 548 int load_status = -1;
535 NaClSrpcResultCodes rpc_result = 549 if (uses_nonsfi_mode_) {
536 NaClSrpcInvokeBySignature(&command_channel_, 550 // In non-SFI mode, we don't need to call start_module SRPC to launch
537 "start_module::i", 551 // the plugin.
538 &load_status); 552 load_status = LOAD_OK;
553 } else {
554 NaClSrpcResultCodes rpc_result =
555 NaClSrpcInvokeBySignature(&command_channel_,
556 "start_module::i",
557 &load_status);
539 558
540 if (NACL_SRPC_RESULT_OK != rpc_result) { 559 if (NACL_SRPC_RESULT_OK != rpc_result) {
541 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_START_MODULE, 560 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_START_MODULE,
542 "ServiceRuntime: could not start nacl module"); 561 "ServiceRuntime: could not start nacl module");
543 return false; 562 return false;
563 }
544 } 564 }
545 NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", 565
546 load_status); 566 NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", load_status);
547 if (main_service_runtime_) { 567 if (main_service_runtime_) {
548 plugin_->ReportSelLdrLoadStatus(load_status); 568 plugin_->ReportSelLdrLoadStatus(load_status);
549 } 569 }
550 if (LOAD_OK != load_status) { 570 if (LOAD_OK != load_status) {
551 error_info->SetReport( 571 error_info->SetReport(
552 PP_NACL_ERROR_SEL_LDR_START_STATUS, 572 PP_NACL_ERROR_SEL_LDR_START_STATUS,
553 NaClErrorString(static_cast<NaClErrorCode>(load_status))); 573 NaClErrorString(static_cast<NaClErrorCode>(load_status)));
554 return false; 574 return false;
555 } 575 }
556 return true; 576 return true;
(...skipping 18 matching lines...) Expand all
575 return; 595 return;
576 } 596 }
577 pp::CompletionCallback internal_callback = 597 pp::CompletionCallback internal_callback =
578 callback_factory_.NewCallback(&ServiceRuntime::StartSelLdrContinuation, 598 callback_factory_.NewCallback(&ServiceRuntime::StartSelLdrContinuation,
579 callback); 599 callback);
580 600
581 tmp_subprocess->Start(plugin_->pp_instance(), 601 tmp_subprocess->Start(plugin_->pp_instance(),
582 params.url.c_str(), 602 params.url.c_str(),
583 params.uses_irt, 603 params.uses_irt,
584 params.uses_ppapi, 604 params.uses_ppapi,
605 params.uses_nonsfi_mode,
585 params.enable_dev_interfaces, 606 params.enable_dev_interfaces,
586 params.enable_dyncode_syscalls, 607 params.enable_dyncode_syscalls,
587 params.enable_exception_handling, 608 params.enable_exception_handling,
588 params.enable_crash_throttling, 609 params.enable_crash_throttling,
589 &start_sel_ldr_error_message_, 610 &start_sel_ldr_error_message_,
590 internal_callback); 611 internal_callback);
591 subprocess_.reset(tmp_subprocess.release()); 612 subprocess_.reset(tmp_subprocess.release());
592 } 613 }
593 614
594 void ServiceRuntime::StartSelLdrContinuation(int32_t pp_error, 615 void ServiceRuntime::StartSelLdrContinuation(int32_t pp_error,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 760
740 nacl::string ServiceRuntime::GetCrashLogOutput() { 761 nacl::string ServiceRuntime::GetCrashLogOutput() {
741 if (NULL != subprocess_.get()) { 762 if (NULL != subprocess_.get()) {
742 return subprocess_->GetCrashLogOutput(); 763 return subprocess_->GetCrashLogOutput();
743 } else { 764 } else {
744 return std::string(); 765 return std::string();
745 } 766 }
746 } 767 }
747 768
748 } // namespace plugin 769 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698