| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 bool service_runtime_started = | 562 bool service_runtime_started = |
| 563 new_service_runtime->Start(wrapper, | 563 new_service_runtime->Start(wrapper, |
| 564 error_info, | 564 error_info, |
| 565 manifest_base_url(), | 565 manifest_base_url(), |
| 566 crash_cb); | 566 crash_cb); |
| 567 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", | 567 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", |
| 568 service_runtime_started)); | 568 service_runtime_started)); |
| 569 if (!service_runtime_started) { | 569 if (!service_runtime_started) { |
| 570 return false; | 570 return false; |
| 571 } | 571 } |
| 572 | |
| 573 // Try to start the Chrome IPC-based proxy. | |
| 574 if (nacl_interface_->StartPpapiProxy(pp_instance())) { | |
| 575 using_ipc_proxy_ = true; | |
| 576 // We need to explicitly schedule this here. It is normally called in | |
| 577 // response to starting the SRPC proxy. | |
| 578 CHECK(init_done_cb.pp_completion_callback().func != NULL); | |
| 579 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon, started ipc proxy.\n")); | |
| 580 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb, PP_OK); | |
| 581 } | |
| 582 return true; | 572 return true; |
| 583 } | 573 } |
| 584 | 574 |
| 585 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, | 575 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, |
| 586 ErrorInfo* error_info, | 576 ErrorInfo* error_info, |
| 587 pp::CompletionCallback init_done_cb, | 577 pp::CompletionCallback init_done_cb, |
| 588 pp::CompletionCallback crash_cb) { | 578 pp::CompletionCallback crash_cb) { |
| 589 // Before forking a new sel_ldr process, ensure that we do not leak | 579 // Before forking a new sel_ldr process, ensure that we do not leak |
| 590 // the ServiceRuntime object for an existing subprocess, and that any | 580 // the ServiceRuntime object for an existing subprocess, and that any |
| 591 // associated listener threads do not go unjoined because if they | 581 // associated listener threads do not go unjoined because if they |
| 592 // outlive the Plugin object, they will not be memory safe. | 582 // outlive the Plugin object, they will not be memory safe. |
| 593 ShutDownSubprocesses(); | 583 ShutDownSubprocesses(); |
| 594 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), | 584 if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), |
| 595 true, error_info, init_done_cb, crash_cb)) { | 585 true, error_info, init_done_cb, crash_cb)) { |
| 596 return false; | 586 return false; |
| 597 } | 587 } |
| 598 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 588 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
| 599 main_subprocess_.detailed_description().c_str())); | 589 main_subprocess_.detailed_description().c_str())); |
| 600 return true; | 590 return true; |
| 601 } | 591 } |
| 602 | 592 |
| 603 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { | 593 bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) { |
| 604 // If we are using the IPC proxy, StartSrpcServices and StartJSObjectProxy | |
| 605 // don't makes sense. Return 'true' so that the plugin continues loading. | |
| 606 if (using_ipc_proxy_) | |
| 607 return true; | |
| 608 | |
| 609 if (!main_subprocess_.StartSrpcServices()) { | 594 if (!main_subprocess_.StartSrpcServices()) { |
| 610 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, | 595 error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL, |
| 611 "SRPC connection failure for " + | 596 "SRPC connection failure for " + |
| 612 main_subprocess_.description()); | 597 main_subprocess_.description()); |
| 613 return false; | 598 return false; |
| 614 } | 599 } |
| 615 if (!main_subprocess_.StartJSObjectProxy(this, error_info)) { | 600 // Try to start the Chrome IPC-based proxy first. If that fails, we |
| 601 // must be using the SRPC proxy. |
| 602 if (!nacl_interface_->StartPpapiProxy(pp_instance()) && |
| 603 !main_subprocess_.StartJSObjectProxy(this, error_info)) { |
| 616 return false; | 604 return false; |
| 617 } | 605 } |
| 618 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 606 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
| 619 main_subprocess_.detailed_description().c_str())); | 607 main_subprocess_.detailed_description().c_str())); |
| 620 return true; | 608 return true; |
| 621 } | 609 } |
| 622 | 610 |
| 623 NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper, | 611 NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper, |
| 624 const Manifest* manifest, | 612 const Manifest* manifest, |
| 625 ErrorInfo* error_info) { | 613 ErrorInfo* error_info) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 nacl_ready_state_(UNSENT), | 819 nacl_ready_state_(UNSENT), |
| 832 nexe_error_reported_(false), | 820 nexe_error_reported_(false), |
| 833 wrapper_factory_(NULL), | 821 wrapper_factory_(NULL), |
| 834 last_error_string_(""), | 822 last_error_string_(""), |
| 835 ppapi_proxy_(NULL), | 823 ppapi_proxy_(NULL), |
| 836 enable_dev_interfaces_(false), | 824 enable_dev_interfaces_(false), |
| 837 init_time_(0), | 825 init_time_(0), |
| 838 ready_time_(0), | 826 ready_time_(0), |
| 839 nexe_size_(0), | 827 nexe_size_(0), |
| 840 time_of_last_progress_event_(0), | 828 time_of_last_progress_event_(0), |
| 841 using_ipc_proxy_(false), | |
| 842 nacl_interface_(NULL) { | 829 nacl_interface_(NULL) { |
| 843 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 830 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
| 844 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 831 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); |
| 845 callback_factory_.Initialize(this); | 832 callback_factory_.Initialize(this); |
| 846 nexe_downloader_.Initialize(this); | 833 nexe_downloader_.Initialize(this); |
| 847 nacl_interface_ = GetNaClInterface(); | 834 nacl_interface_ = GetNaClInterface(); |
| 848 CHECK(nacl_interface_ != NULL); | 835 CHECK(nacl_interface_ != NULL); |
| 849 } | 836 } |
| 850 | 837 |
| 851 | 838 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 static_cast<uint32_t>(text.size())); | 1885 static_cast<uint32_t>(text.size())); |
| 1899 const PPB_Console_Dev* console_interface = | 1886 const PPB_Console_Dev* console_interface = |
| 1900 static_cast<const PPB_Console_Dev*>( | 1887 static_cast<const PPB_Console_Dev*>( |
| 1901 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); | 1888 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); |
| 1902 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1889 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
| 1903 var_interface->Release(prefix); | 1890 var_interface->Release(prefix); |
| 1904 var_interface->Release(str); | 1891 var_interface->Release(str); |
| 1905 } | 1892 } |
| 1906 | 1893 |
| 1907 } // namespace plugin | 1894 } // namespace plugin |
| OLD | NEW |