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

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: fixes for bbudge 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
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 return nexe_started_ok_; 452 return nexe_started_ok_;
453 } 453 }
454 454
455 void ServiceRuntime::SignalNexeStarted(bool ok) { 455 void ServiceRuntime::SignalNexeStarted(bool ok) {
456 nacl::MutexLocker take(&mu_); 456 nacl::MutexLocker take(&mu_);
457 start_nexe_done_ = true; 457 start_nexe_done_ = true;
458 nexe_started_ok_ = ok; 458 nexe_started_ok_ = ok;
459 NaClXCondVarSignal(&cond_); 459 NaClXCondVarSignal(&cond_);
460 } 460 }
461 461
462 void ServiceRuntime::LoadNexeAndStart(PP_NaClFileInfo file_info) { 462 void ServiceRuntime::LoadNexeAndStart() {
463 NaClLog(4, "ServiceRuntime::LoadNexeAndStart (handle_valid=%d " 463 bool ok = LoadNexeAndStartInternal();
464 "token_lo=%" NACL_PRIu64 " token_hi=%" NACL_PRIu64 ")\n",
465 file_info.handle != PP_kInvalidFileHandle,
466 file_info.token_lo,
467 file_info.token_hi);
468
469 bool ok = LoadNexeAndStartInternal(file_info);
470 if (ok) { 464 if (ok) {
471 NaClLog(4, "ServiceRuntime::LoadNexeAndStart (success)\n"); 465 NaClLog(4, "ServiceRuntime::LoadNexeAndStart (success)\n");
472 } else { 466 } else {
473 ReapLogs(); 467 ReapLogs();
474 } 468 }
475 // This only matters if a background thread is waiting, but we signal in all 469 // This only matters if a background thread is waiting, but we signal in all
476 // cases to simplify the code. 470 // cases to simplify the code.
477 SignalNexeStarted(ok); 471 SignalNexeStarted(ok);
478 } 472 }
479 473
480 bool ServiceRuntime::LoadNexeAndStartInternal( 474 bool ServiceRuntime::LoadNexeAndStartInternal() {
481 const PP_NaClFileInfo& file_info) {
482 if(!SetupCommandChannel()) { 475 if(!SetupCommandChannel()) {
483 return false; 476 return false;
484 } 477 }
485 if (!InitReverseService()) { 478 if (!InitReverseService()) {
486 return false; 479 return false;
487 } 480 }
488 if (!LoadModule(file_info)) { 481 return StartModule();
489 ErrorInfo error_info;
490 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL,
491 "ServiceRuntime: load module failed");
492 ReportLoadError(error_info);
493 return false;
494 }
495 if (!StartModule()) {
496 return false;
497 }
498 return true;
499 }
500
501 bool ServiceRuntime::LoadModule(const PP_NaClFileInfo& file_info) {
502 if (uses_nonsfi_mode_) {
503 // In non-SFI mode, loading is done a part of LaunchSelLdr.
504 return true;
505 }
506
507 NaClFileInfo nacl_file_info;
508 nacl_file_info.desc = ConvertFileDescriptor(file_info.handle, true);
509 nacl_file_info.file_token.lo = file_info.token_lo;
510 nacl_file_info.file_token.hi = file_info.token_hi;
511 NaClDesc* desc = NaClDescIoFromFileInfo(nacl_file_info, O_RDONLY);
512 if (desc == NULL) {
513 return false;
514 }
515 // We don't use a scoped_ptr here since we would immediately release the
516 // DescWrapper to LoadModule().
517 nacl::DescWrapper* wrapper =
518 plugin_->wrapper_factory()->MakeGenericCleanup(desc);
519 // TODO(teravest, hidehiko): Replace this by Chrome IPC.
520 return subprocess_->LoadModule(&command_channel_, wrapper);
521 } 482 }
522 483
523 void ServiceRuntime::ReapLogs() { 484 void ServiceRuntime::ReapLogs() {
524 // On a load failure the service runtime does not crash itself to 485 // On a load failure the service runtime does not crash itself to
525 // avoid a race where the no-more-senders error on the reverse 486 // avoid a race where the no-more-senders error on the reverse
526 // channel service thread might cause the crash-detection logic to 487 // channel service thread might cause the crash-detection logic to
527 // kick in before the start_module RPC reply has been received. So 488 // kick in before the start_module RPC reply has been received. So
528 // we induce a service runtime crash here. We do not release 489 // we induce a service runtime crash here. We do not release
529 // subprocess_ since it's needed to collect crash log output after 490 // subprocess_ since it's needed to collect crash log output after
530 // the error is reported. 491 // the error is reported.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 585
625 nacl::string ServiceRuntime::GetCrashLogOutput() { 586 nacl::string ServiceRuntime::GetCrashLogOutput() {
626 if (NULL != subprocess_.get()) { 587 if (NULL != subprocess_.get()) {
627 return subprocess_->GetCrashLogOutput(); 588 return subprocess_->GetCrashLogOutput();
628 } else { 589 } else {
629 return std::string(); 590 return std::string();
630 } 591 }
631 } 592 }
632 593
633 } // namespace plugin 594 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698