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 "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 #include "native_client/src/include/nacl_scoped_ptr.h" | 27 #include "native_client/src/include/nacl_scoped_ptr.h" |
28 #include "native_client/src/include/nacl_string.h" | 28 #include "native_client/src/include/nacl_string.h" |
29 #include "native_client/src/include/portability.h" | 29 #include "native_client/src/include/portability.h" |
30 #include "native_client/src/include/portability_io.h" | 30 #include "native_client/src/include/portability_io.h" |
31 #include "native_client/src/include/portability_string.h" | 31 #include "native_client/src/include/portability_string.h" |
32 #include "native_client/src/shared/platform/nacl_check.h" | 32 #include "native_client/src/shared/platform/nacl_check.h" |
33 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 33 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
34 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 34 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
35 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 35 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
36 #include "native_client/src/trusted/plugin/json_manifest.h" | 36 #include "native_client/src/trusted/plugin/json_manifest.h" |
37 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | |
37 #include "native_client/src/trusted/plugin/nacl_subprocess.h" | 38 #include "native_client/src/trusted/plugin/nacl_subprocess.h" |
38 #include "native_client/src/trusted/plugin/nexe_arch.h" | 39 #include "native_client/src/trusted/plugin/nexe_arch.h" |
39 #include "native_client/src/trusted/plugin/plugin_error.h" | 40 #include "native_client/src/trusted/plugin/plugin_error.h" |
40 #include "native_client/src/trusted/plugin/scriptable_plugin.h" | 41 #include "native_client/src/trusted/plugin/scriptable_plugin.h" |
41 #include "native_client/src/trusted/plugin/service_runtime.h" | 42 #include "native_client/src/trusted/plugin/service_runtime.h" |
42 #include "native_client/src/trusted/plugin/utility.h" | 43 #include "native_client/src/trusted/plugin/utility.h" |
43 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 44 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
44 | 45 |
45 #include "ppapi/c/dev/ppb_console_dev.h" | 46 #include "ppapi/c/dev/ppb_console_dev.h" |
46 #include "ppapi/c/dev/ppp_find_dev.h" | 47 #include "ppapi/c/dev/ppp_find_dev.h" |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 return false; | 603 return false; |
603 } | 604 } |
604 | 605 |
605 bool service_runtime_started = | 606 bool service_runtime_started = |
606 new_service_runtime->Start(wrapper, error_info, manifest_base_url()); | 607 new_service_runtime->Start(wrapper, error_info, manifest_base_url()); |
607 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", | 608 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", |
608 service_runtime_started)); | 609 service_runtime_started)); |
609 if (!service_runtime_started) { | 610 if (!service_runtime_started) { |
610 return false; | 611 return false; |
611 } | 612 } |
613 if (start_ppapi_proxy && start_ppapi_proxy(pp_instance())) { | |
614 started_ipc_proxy_ = true; | |
615 if (init_done_cb.pp_completion_callback().func != NULL) { | |
Mark Seaborn
2012/06/20 19:24:40
Is there is reason this isn't just CHECK(init_done
bbudge
2012/06/21 00:00:46
Done.
| |
616 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon, started ipc proxy.\n")); | |
617 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb, PP_OK); | |
618 } else { | |
619 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon, init_done_cb invalid.\n")); | |
620 return false; | |
621 } | |
622 } | |
612 return true; | 623 return true; |
613 } | 624 } |
614 | 625 |
615 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, | 626 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, |
616 ErrorInfo* error_info, | 627 ErrorInfo* error_info, |
617 pp::CompletionCallback init_done_cb, | 628 pp::CompletionCallback init_done_cb, |
618 pp::CompletionCallback crash_cb) { | 629 pp::CompletionCallback crash_cb) { |
619 // Before forking a new sel_ldr process, ensure that we do not leak | 630 // Before forking a new sel_ldr process, ensure that we do not leak |
620 // the ServiceRuntime object for an existing subprocess, and that any | 631 // the ServiceRuntime object for an existing subprocess, and that any |
621 // associated listener threads do not go unjoined because if they | 632 // associated listener threads do not go unjoined because if they |
622 // outlive the Plugin object, they will not be memory safe. | 633 // outlive the Plugin object, they will not be memory safe. |
623 ShutDownSubprocesses(); | 634 ShutDownSubprocesses(); |
624 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), | 635 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), |
625 true, error_info, init_done_cb, crash_cb)) { | 636 true, error_info, init_done_cb, crash_cb)) { |
626 return false; | 637 return false; |
627 } | 638 } |
628 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 639 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
629 main_subprocess_.detailed_description().c_str())); | 640 main_subprocess_.detailed_description().c_str())); |
630 return true; | 641 return true; |
631 } | 642 } |
632 | 643 |
633 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { | 644 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { |
645 if (started_ipc_proxy_) | |
dmichael (off chromium)
2012/06/20 22:34:32
We should probably add a comment here about why we
bbudge
2012/06/21 00:00:46
Done.
| |
646 return true; | |
647 | |
634 if (!main_subprocess_.StartSrpcServices()) { | 648 if (!main_subprocess_.StartSrpcServices()) { |
635 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, | 649 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, |
636 "SRPC connection failure for " + | 650 "SRPC connection failure for " + |
637 main_subprocess_.description()); | 651 main_subprocess_.description()); |
638 return false; | 652 return false; |
639 } | 653 } |
640 if (!main_subprocess_.StartJSObjectProxy(this, error_info)) { | 654 if (!main_subprocess_.StartJSObjectProxy(this, error_info)) { |
641 return false; | 655 return false; |
642 } | 656 } |
643 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 657 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 main_subprocess_("main subprocess", NULL, NULL), | 869 main_subprocess_("main subprocess", NULL, NULL), |
856 nacl_ready_state_(UNSENT), | 870 nacl_ready_state_(UNSENT), |
857 nexe_error_reported_(false), | 871 nexe_error_reported_(false), |
858 wrapper_factory_(NULL), | 872 wrapper_factory_(NULL), |
859 last_error_string_(""), | 873 last_error_string_(""), |
860 ppapi_proxy_(NULL), | 874 ppapi_proxy_(NULL), |
861 enable_dev_interfaces_(false), | 875 enable_dev_interfaces_(false), |
862 init_time_(0), | 876 init_time_(0), |
863 ready_time_(0), | 877 ready_time_(0), |
864 nexe_size_(0), | 878 nexe_size_(0), |
865 time_of_last_progress_event_(0) { | 879 time_of_last_progress_event_(0), |
880 started_ipc_proxy_(false) { | |
866 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 881 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
867 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 882 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); |
868 callback_factory_.Initialize(this); | 883 callback_factory_.Initialize(this); |
869 nexe_downloader_.Initialize(this); | 884 nexe_downloader_.Initialize(this); |
870 } | 885 } |
871 | 886 |
872 | 887 |
873 Plugin::~Plugin() { | 888 Plugin::~Plugin() { |
874 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); | 889 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); |
875 | 890 |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 static_cast<uint32_t>(text.size())); | 1902 static_cast<uint32_t>(text.size())); |
1888 const PPB_Console_Dev* console_interface = | 1903 const PPB_Console_Dev* console_interface = |
1889 static_cast<const PPB_Console_Dev*>( | 1904 static_cast<const PPB_Console_Dev*>( |
1890 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); | 1905 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); |
1891 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1906 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
1892 var_interface->Release(prefix); | 1907 var_interface->Release(prefix); |
1893 var_interface->Release(str); | 1908 var_interface->Release(str); |
1894 } | 1909 } |
1895 | 1910 |
1896 } // namespace plugin | 1911 } // namespace plugin |
OLD | NEW |