| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 5 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
| 6 | 6 |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 397 } |
| 398 | 398 |
| 399 void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { | 399 void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { |
| 400 UNREFERENCED_PARAMETER(pp_error); | 400 UNREFERENCED_PARAMETER(pp_error); |
| 401 NaClLog(4, "Entered NexeFileDidOpenContinuation\n"); | 401 NaClLog(4, "Entered NexeFileDidOpenContinuation\n"); |
| 402 if (LoadNaClModuleContinuationIntern()) { | 402 if (LoadNaClModuleContinuationIntern()) { |
| 403 NaClLog(4, "NexeFileDidOpenContinuation: success;" | 403 NaClLog(4, "NexeFileDidOpenContinuation: success;" |
| 404 " setting histograms\n"); | 404 " setting histograms\n"); |
| 405 int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance()); | 405 int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance()); |
| 406 nacl_interface_->ReportLoadSuccess( | 406 nacl_interface_->ReportLoadSuccess( |
| 407 pp_instance(), program_url_.c_str(), nexe_size, nexe_size); | 407 pp_instance(), nexe_size, nexe_size); |
| 408 } else { | 408 } else { |
| 409 NaClLog(4, "NexeFileDidOpenContinuation: failed."); | 409 NaClLog(4, "NexeFileDidOpenContinuation: failed."); |
| 410 } | 410 } |
| 411 NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); | 411 NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); |
| 412 } | 412 } |
| 413 | 413 |
| 414 void Plugin::NexeDidCrash(int32_t pp_error) { | 414 void Plugin::NexeDidCrash(int32_t pp_error) { |
| 415 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", | 415 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", |
| 416 pp_error)); | 416 pp_error)); |
| 417 if (pp_error != PP_OK) { | 417 if (pp_error != PP_OK) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) { | 453 void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) { |
| 454 NaClLog(4, "Entered BitcodeDidTranslateContinuation\n"); | 454 NaClLog(4, "Entered BitcodeDidTranslateContinuation\n"); |
| 455 UNREFERENCED_PARAMETER(pp_error); | 455 UNREFERENCED_PARAMETER(pp_error); |
| 456 if (LoadNaClModuleContinuationIntern()) { | 456 if (LoadNaClModuleContinuationIntern()) { |
| 457 int64_t loaded; | 457 int64_t loaded; |
| 458 int64_t total; | 458 int64_t total; |
| 459 // TODO(teravest): Tighten this up so we can get rid of | 459 // TODO(teravest): Tighten this up so we can get rid of |
| 460 // GetCurrentProgress(). loaded should always equal total. | 460 // GetCurrentProgress(). loaded should always equal total. |
| 461 pnacl_coordinator_->GetCurrentProgress(&loaded, &total); | 461 pnacl_coordinator_->GetCurrentProgress(&loaded, &total); |
| 462 nacl_interface_->ReportLoadSuccess( | 462 nacl_interface_->ReportLoadSuccess(pp_instance(), loaded, total); |
| 463 pp_instance(), program_url_.c_str(), loaded, total); | |
| 464 } | 463 } |
| 465 } | 464 } |
| 466 | 465 |
| 467 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { | 466 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { |
| 468 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" | 467 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" |
| 469 NACL_PRId32 ")\n", pp_error)); | 468 NACL_PRId32 ")\n", pp_error)); |
| 470 if (pp_error != PP_OK) | 469 if (pp_error != PP_OK) |
| 471 return; | 470 return; |
| 472 | 471 |
| 473 PP_Var pp_program_url; | 472 PP_Var pp_program_url; |
| 474 PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, 2}; | 473 PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, 2}; |
| 475 PP_Bool uses_nonsfi_mode; | 474 PP_Bool uses_nonsfi_mode; |
| 476 if (nacl_interface_->GetManifestProgramURL( | 475 if (nacl_interface_->GetManifestProgramURL( |
| 477 pp_instance(), &pp_program_url, &pnacl_options, &uses_nonsfi_mode)) { | 476 pp_instance(), &pp_program_url, &pnacl_options, &uses_nonsfi_mode)) { |
| 478 program_url_ = pp::Var(pp::PASS_REF, pp_program_url).AsString(); | 477 std::string program_url = pp::Var(pp::PASS_REF, pp_program_url).AsString(); |
| 479 // TODO(teravest): Make ProcessNaClManifest take responsibility for more of | 478 // TODO(teravest): Make ProcessNaClManifest take responsibility for more of |
| 480 // this function. | 479 // this function. |
| 481 nacl_interface_->ProcessNaClManifest(pp_instance(), program_url_.c_str()); | 480 nacl_interface_->ProcessNaClManifest(pp_instance(), program_url.c_str()); |
| 482 uses_nonsfi_mode_ = PP_ToBool(uses_nonsfi_mode); | 481 uses_nonsfi_mode_ = PP_ToBool(uses_nonsfi_mode); |
| 483 if (pnacl_options.translate) { | 482 if (pnacl_options.translate) { |
| 484 pp::CompletionCallback translate_callback = | 483 pp::CompletionCallback translate_callback = |
| 485 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); | 484 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); |
| 486 pnacl_coordinator_.reset( | 485 pnacl_coordinator_.reset( |
| 487 PnaclCoordinator::BitcodeToNative(this, | 486 PnaclCoordinator::BitcodeToNative(this, |
| 488 program_url_, | 487 program_url, |
| 489 pnacl_options, | 488 pnacl_options, |
| 490 translate_callback)); | 489 translate_callback)); |
| 491 return; | 490 return; |
| 492 } else { | 491 } else { |
| 493 pp::CompletionCallback open_callback = | 492 pp::CompletionCallback open_callback = |
| 494 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); | 493 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); |
| 495 // Will always call the callback on success or failure. | 494 // Will always call the callback on success or failure. |
| 496 nacl_interface_->DownloadNexe(pp_instance(), | 495 nacl_interface_->DownloadNexe(pp_instance(), |
| 497 program_url_.c_str(), | 496 program_url.c_str(), |
| 498 &nexe_file_info_, | 497 &nexe_file_info_, |
| 499 open_callback.pp_completion_callback()); | 498 open_callback.pp_completion_callback()); |
| 500 return; | 499 return; |
| 501 } | 500 } |
| 502 } | 501 } |
| 503 } | 502 } |
| 504 | 503 |
| 505 void Plugin::ReportLoadError(const ErrorInfo& error_info) { | 504 void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
| 506 nacl_interface_->ReportLoadError(pp_instance(), | 505 nacl_interface_->ReportLoadError(pp_instance(), |
| 507 error_info.error_code(), | 506 error_info.error_code(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 528 | 527 |
| 529 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 528 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, |
| 530 int exit_status) { | 529 int exit_status) { |
| 531 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 530 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
| 532 DCHECK(nacl_interface_); | 531 DCHECK(nacl_interface_); |
| 533 nacl_interface_->SetExitStatus(pp_instance(), exit_status); | 532 nacl_interface_->SetExitStatus(pp_instance(), exit_status); |
| 534 } | 533 } |
| 535 | 534 |
| 536 | 535 |
| 537 } // namespace plugin | 536 } // namespace plugin |
| OLD | NEW |