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

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

Issue 332463003: Pepper: Remove LOAD_MODULE SRPC call in SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comment to forward declaration Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/service_runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 return nexe_started_ok_; 459 return nexe_started_ok_;
460 } 460 }
461 461
462 void ServiceRuntime::SignalNexeStarted(bool ok) { 462 void ServiceRuntime::SignalNexeStarted(bool ok) {
463 nacl::MutexLocker take(&mu_); 463 nacl::MutexLocker take(&mu_);
464 start_nexe_done_ = true; 464 start_nexe_done_ = true;
465 nexe_started_ok_ = ok; 465 nexe_started_ok_ = ok;
466 NaClXCondVarSignal(&cond_); 466 NaClXCondVarSignal(&cond_);
467 } 467 }
468 468
469 void ServiceRuntime::LoadNexeAndStart(PP_NaClFileInfo file_info) { 469 void ServiceRuntime::StartNexe() {
470 NaClLog(4, "ServiceRuntime::LoadNexeAndStart (handle_valid=%d " 470 bool ok = StartNexeInternal();
471 "token_lo=%" NACL_PRIu64 " token_hi=%" NACL_PRIu64 ")\n",
472 file_info.handle != PP_kInvalidFileHandle,
473 file_info.token_lo,
474 file_info.token_hi);
475
476 bool ok = LoadNexeAndStartInternal(file_info);
477 if (ok) { 471 if (ok) {
478 NaClLog(4, "ServiceRuntime::LoadNexeAndStart (success)\n"); 472 NaClLog(4, "ServiceRuntime::StartNexe (success)\n");
479 } else { 473 } else {
480 ReapLogs(); 474 ReapLogs();
481 } 475 }
482 // This only matters if a background thread is waiting, but we signal in all 476 // This only matters if a background thread is waiting, but we signal in all
483 // cases to simplify the code. 477 // cases to simplify the code.
484 SignalNexeStarted(ok); 478 SignalNexeStarted(ok);
485 } 479 }
486 480
487 bool ServiceRuntime::LoadNexeAndStartInternal( 481 bool ServiceRuntime::StartNexeInternal() {
488 const PP_NaClFileInfo& file_info) { 482 if (!SetupCommandChannel())
489 if(!SetupCommandChannel()) {
490 return false; 483 return false;
491 } 484 if (!InitReverseService())
492 if (!InitReverseService()) {
493 return false; 485 return false;
494 } 486 return StartModule();
495 if (!LoadModule(file_info)) {
496 ErrorInfo error_info;
497 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL,
498 "ServiceRuntime: load module failed");
499 ReportLoadError(error_info);
500 return false;
501 }
502 if (!StartModule()) {
503 return false;
504 }
505 return true;
506 }
507
508 bool ServiceRuntime::LoadModule(const PP_NaClFileInfo& file_info) {
509 if (uses_nonsfi_mode_) {
510 // In non-SFI mode, loading is done a part of LaunchSelLdr.
511 return true;
512 }
513
514 NaClFileInfo nacl_file_info;
515 nacl_file_info.desc = ConvertFileDescriptor(file_info.handle, true);
516 nacl_file_info.file_token.lo = file_info.token_lo;
517 nacl_file_info.file_token.hi = file_info.token_hi;
518 NaClDesc* desc = NaClDescIoFromFileInfo(nacl_file_info, O_RDONLY);
519 if (desc == NULL) {
520 return false;
521 }
522 // We don't use a scoped_ptr here since we would immediately release the
523 // DescWrapper to LoadModule().
524 nacl::DescWrapper* wrapper =
525 plugin_->wrapper_factory()->MakeGenericCleanup(desc);
526 // TODO(teravest, hidehiko): Replace this by Chrome IPC.
527 return subprocess_->LoadModule(&command_channel_, wrapper);
528 } 487 }
529 488
530 void ServiceRuntime::ReapLogs() { 489 void ServiceRuntime::ReapLogs() {
531 // On a load failure the service runtime does not crash itself to 490 // On a load failure the service runtime does not crash itself to
532 // avoid a race where the no-more-senders error on the reverse 491 // avoid a race where the no-more-senders error on the reverse
533 // channel service thread might cause the crash-detection logic to 492 // channel service thread might cause the crash-detection logic to
534 // kick in before the start_module RPC reply has been received. So 493 // kick in before the start_module RPC reply has been received. So
535 // we induce a service runtime crash here. We do not release 494 // we induce a service runtime crash here. We do not release
536 // subprocess_ since it's needed to collect crash log output after 495 // subprocess_ since it's needed to collect crash log output after
537 // the error is reported. 496 // the error is reported.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 590
632 nacl::string ServiceRuntime::GetCrashLogOutput() { 591 nacl::string ServiceRuntime::GetCrashLogOutput() {
633 if (NULL != subprocess_.get()) { 592 if (NULL != subprocess_.get()) {
634 return subprocess_->GetCrashLogOutput(); 593 return subprocess_->GetCrashLogOutput();
635 } else { 594 } else {
636 return std::string(); 595 return std::string();
637 } 596 }
638 } 597 }
639 598
640 } // namespace plugin 599 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/service_runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698