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 using_ipc_proxy_ = true; | |
615 CHECK(init_done_cb.pp_completion_callback().func != NULL); | |
616 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon, started ipc proxy.\n")); | |
617 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb, PP_OK); | |
dmichael (off chromium)
2012/06/21 18:18:16
We probably ought to comment to explain this too..
bbudge
2012/06/21 19:28:18
Done.
| |
618 } | |
612 return true; | 619 return true; |
613 } | 620 } |
614 | 621 |
615 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, | 622 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, |
616 ErrorInfo* error_info, | 623 ErrorInfo* error_info, |
617 pp::CompletionCallback init_done_cb, | 624 pp::CompletionCallback init_done_cb, |
618 pp::CompletionCallback crash_cb) { | 625 pp::CompletionCallback crash_cb) { |
619 // Before forking a new sel_ldr process, ensure that we do not leak | 626 // Before forking a new sel_ldr process, ensure that we do not leak |
620 // the ServiceRuntime object for an existing subprocess, and that any | 627 // the ServiceRuntime object for an existing subprocess, and that any |
621 // associated listener threads do not go unjoined because if they | 628 // associated listener threads do not go unjoined because if they |
622 // outlive the Plugin object, they will not be memory safe. | 629 // outlive the Plugin object, they will not be memory safe. |
623 ShutDownSubprocesses(); | 630 ShutDownSubprocesses(); |
624 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), | 631 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), |
625 true, error_info, init_done_cb, crash_cb)) { | 632 true, error_info, init_done_cb, crash_cb)) { |
626 return false; | 633 return false; |
627 } | 634 } |
628 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 635 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
629 main_subprocess_.detailed_description().c_str())); | 636 main_subprocess_.detailed_description().c_str())); |
630 return true; | 637 return true; |
631 } | 638 } |
632 | 639 |
633 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { | 640 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { |
641 // If we are using the IPC proxy, StartSrpcServices and StartJSObjectProxy | |
642 // don't makes sense. Return 'true' so that the plugin continues loading. | |
643 if (using_ipc_proxy_) | |
644 return true; | |
645 | |
634 if (!main_subprocess_.StartSrpcServices()) { | 646 if (!main_subprocess_.StartSrpcServices()) { |
635 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, | 647 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, |
636 "SRPC connection failure for " + | 648 "SRPC connection failure for " + |
637 main_subprocess_.description()); | 649 main_subprocess_.description()); |
638 return false; | 650 return false; |
639 } | 651 } |
640 if (!main_subprocess_.StartJSObjectProxy(this, error_info)) { | 652 if (!main_subprocess_.StartJSObjectProxy(this, error_info)) { |
641 return false; | 653 return false; |
642 } | 654 } |
643 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 655 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), | 867 main_subprocess_("main subprocess", NULL, NULL), |
856 nacl_ready_state_(UNSENT), | 868 nacl_ready_state_(UNSENT), |
857 nexe_error_reported_(false), | 869 nexe_error_reported_(false), |
858 wrapper_factory_(NULL), | 870 wrapper_factory_(NULL), |
859 last_error_string_(""), | 871 last_error_string_(""), |
860 ppapi_proxy_(NULL), | 872 ppapi_proxy_(NULL), |
861 enable_dev_interfaces_(false), | 873 enable_dev_interfaces_(false), |
862 init_time_(0), | 874 init_time_(0), |
863 ready_time_(0), | 875 ready_time_(0), |
864 nexe_size_(0), | 876 nexe_size_(0), |
865 time_of_last_progress_event_(0) { | 877 time_of_last_progress_event_(0), |
878 using_ipc_proxy_(false) { | |
866 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 879 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
867 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 880 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); |
868 callback_factory_.Initialize(this); | 881 callback_factory_.Initialize(this); |
869 nexe_downloader_.Initialize(this); | 882 nexe_downloader_.Initialize(this); |
870 } | 883 } |
871 | 884 |
872 | 885 |
873 Plugin::~Plugin() { | 886 Plugin::~Plugin() { |
874 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); | 887 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); |
875 | 888 |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 static_cast<uint32_t>(text.size())); | 1900 static_cast<uint32_t>(text.size())); |
1888 const PPB_Console_Dev* console_interface = | 1901 const PPB_Console_Dev* console_interface = |
1889 static_cast<const PPB_Console_Dev*>( | 1902 static_cast<const PPB_Console_Dev*>( |
1890 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); | 1903 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); |
1891 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1904 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
1892 var_interface->Release(prefix); | 1905 var_interface->Release(prefix); |
1893 var_interface->Release(str); | 1906 var_interface->Release(str); |
1894 } | 1907 } |
1895 | 1908 |
1896 } // namespace plugin | 1909 } // namespace plugin |
OLD | NEW |