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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
8 #endif | 8 #endif |
9 | 9 |
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 | 575 |
576 Plugin::Plugin(PP_Instance pp_instance) | 576 Plugin::Plugin(PP_Instance pp_instance) |
577 : pp::Instance(pp_instance), | 577 : pp::Instance(pp_instance), |
578 main_subprocess_("main subprocess", NULL, NULL), | 578 main_subprocess_("main subprocess", NULL, NULL), |
579 uses_nonsfi_mode_(false), | 579 uses_nonsfi_mode_(false), |
580 wrapper_factory_(NULL), | 580 wrapper_factory_(NULL), |
581 enable_dev_interfaces_(false), | 581 enable_dev_interfaces_(false), |
582 init_time_(0), | 582 init_time_(0), |
583 nexe_size_(0), | 583 nexe_size_(0), |
584 time_of_last_progress_event_(0), | 584 time_of_last_progress_event_(0), |
585 exit_status_(-1), | |
586 nacl_interface_(NULL), | 585 nacl_interface_(NULL), |
587 uma_interface_(this) { | 586 uma_interface_(this) { |
588 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 587 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
589 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); | 588 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); |
590 callback_factory_.Initialize(this); | 589 callback_factory_.Initialize(this); |
591 nexe_downloader_.Initialize(this); | 590 nexe_downloader_.Initialize(this); |
592 nacl_interface_ = GetNaClInterface(); | 591 nacl_interface_ = GetNaClInterface(); |
593 CHECK(nacl_interface_ != NULL); | 592 CHECK(nacl_interface_ != NULL); |
594 | 593 |
595 // Notify PPB_NaCl_Private that the instance is created before altering any | 594 // Notify PPB_NaCl_Private that the instance is created before altering any |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 } | 803 } |
805 | 804 |
806 void Plugin::NexeDidCrash(int32_t pp_error) { | 805 void Plugin::NexeDidCrash(int32_t pp_error) { |
807 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", | 806 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", |
808 pp_error)); | 807 pp_error)); |
809 if (pp_error != PP_OK) { | 808 if (pp_error != PP_OK) { |
810 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" | 809 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" |
811 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); | 810 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); |
812 } | 811 } |
813 PLUGIN_PRINTF(("Plugin::NexeDidCrash: crash event!\n")); | 812 PLUGIN_PRINTF(("Plugin::NexeDidCrash: crash event!\n")); |
814 if (-1 != exit_status()) { | 813 int exit_status = nacl_interface_->GetExitStatus(pp_instance()); |
814 if (exit_status != -1) { | |
dmichael (off chromium)
2014/04/02 19:01:41
Pardon the stupid question, but is -1 a viable exi
| |
815 // The NaCl module voluntarily exited. However, this is still a | 815 // The NaCl module voluntarily exited. However, this is still a |
816 // crash from the point of view of Pepper, since PPAPI plugins are | 816 // crash from the point of view of Pepper, since PPAPI plugins are |
817 // event handlers and should never exit. | 817 // event handlers and should never exit. |
818 PLUGIN_PRINTF((("Plugin::NexeDidCrash: nexe exited with status %d" | 818 PLUGIN_PRINTF((("Plugin::NexeDidCrash: nexe exited with status %d" |
819 " so this is a \"controlled crash\".\n"), | 819 " so this is a \"controlled crash\".\n"), |
820 exit_status())); | 820 exit_status)); |
821 } | 821 } |
822 // If the crash occurs during load, we just want to report an error | 822 // If the crash occurs during load, we just want to report an error |
823 // that fits into our load progress event grammar. If the crash | 823 // that fits into our load progress event grammar. If the crash |
824 // occurs after loaded/loadend, then we use ReportDeadNexe to send a | 824 // occurs after loaded/loadend, then we use ReportDeadNexe to send a |
825 // "crash" event. | 825 // "crash" event. |
826 if (nacl_interface_->GetNexeErrorReported(pp_instance())) { | 826 if (nacl_interface_->GetNexeErrorReported(pp_instance())) { |
827 PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;" | 827 PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;" |
828 " suppressing\n")); | 828 " suppressing\n")); |
829 } else { | 829 } else { |
830 if (nacl_interface_->GetNaClReadyState(pp_instance()) == | 830 if (nacl_interface_->GetNaClReadyState(pp_instance()) == |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 callback_factory_.NewCallback(&Plugin::SetExitStatusOnMainThread, | 1365 callback_factory_.NewCallback(&Plugin::SetExitStatusOnMainThread, |
1366 exit_status); | 1366 exit_status); |
1367 core->CallOnMainThread(0, callback, 0); | 1367 core->CallOnMainThread(0, callback, 0); |
1368 } | 1368 } |
1369 } | 1369 } |
1370 | 1370 |
1371 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 1371 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, |
1372 int exit_status) { | 1372 int exit_status) { |
1373 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 1373 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
1374 DCHECK(nacl_interface_); | 1374 DCHECK(nacl_interface_); |
1375 exit_status_ = exit_status; | 1375 nacl_interface_->SetExitStatus(pp_instance(), exit_status); |
1376 nacl_interface_->SetReadOnlyProperty(pp_instance(), | |
1377 pp::Var("exitStatus").pp_var(), | |
1378 pp::Var(exit_status_).pp_var()); | |
1379 } | 1376 } |
1380 | 1377 |
1381 | 1378 |
1382 } // namespace plugin | 1379 } // namespace plugin |
OLD | NEW |