diff options
5 files changed, 72 insertions, 3 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.gypi b/ppapi/native_client/src/trusted/plugin/plugin.gypi index c891f28..df9154f 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.gypi +++ b/ppapi/native_client/src/trusted/plugin/plugin.gypi @@ -15,6 +15,7 @@ 'pnacl_coordinator.cc', 'pnacl_resources.cc', 'scriptable_plugin.cc', + 'sel_ldr_launcher_chrome.cc', 'service_runtime.cc', 'srpc_client.cc', 'srpc_params.cc', diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc new file mode 100644 index 0000000..f5b6c9f --- /dev/null +++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" + +#include "native_client/src/trusted/plugin/nacl_entry_points.h" + +#if NACL_WINDOWS +# include <windows.h> +#endif + +LaunchNaClProcessFunc launch_nacl_process = NULL; + +namespace plugin { + +bool SelLdrLauncherChrome::Start(const char* url) { + // send a synchronous message to the browser process + // TODO(mseaborn): Remove the nacl_proc_handle and nacl_proc_id + // arguments. Chromium is being changed not to give the renderer + // the Windows handle of the NaCl process. + nacl::Handle nacl_proc_handle; + int nacl_proc_id; + // TODO(sehr): This is asserted to be one. Remove this parameter. + static const int kNumberOfChannelsToBeCreated = 1; + if (!launch_nacl_process || + !launch_nacl_process(url, + kNumberOfChannelsToBeCreated, + &channel_, + &nacl_proc_handle, + &nacl_proc_id)) { + return false; + } + +#if NACL_WINDOWS + if (nacl_proc_handle != nacl::kInvalidHandle && + nacl_proc_handle != NULL) { + CloseHandle(nacl_proc_handle); + } +#endif + return true; +} + +} // namespace plugin diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h new file mode 100644 index 0000000..2450cf3 --- /dev/null +++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h @@ -0,0 +1,19 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SEL_LDR_LAUNCHER_CHROME_H_ +#define PPAPI_NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SEL_LDR_LAUNCHER_CHROME_H_ + +#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" + +namespace plugin { + +class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase { + public: + virtual bool Start(const char* url); +}; + +} // namespace plugin + +#endif diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc index 37a836d..8a75b1e 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -45,6 +45,7 @@ #include "native_client/src/trusted/plugin/plugin.h" #include "native_client/src/trusted/plugin/plugin_error.h" #include "native_client/src/trusted/plugin/pnacl_coordinator.h" +#include "native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" #include "native_client/src/trusted/plugin/srpc_client.h" #include "native_client/src/trusted/plugin/utility.h" @@ -627,8 +628,12 @@ bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc, PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n", reinterpret_cast<void*>(nacl_desc))); - nacl::scoped_ptr<nacl::SelLdrLauncher> - tmp_subprocess(new nacl::SelLdrLauncher()); + nacl::scoped_ptr<nacl::SelLdrLauncherBase> tmp_subprocess; +#ifdef NACL_STANDALONE + tmp_subprocess.reset(new nacl::SelLdrLauncherStandalone()); +#else + tmp_subprocess.reset(new SelLdrLauncherChrome()); +#endif if (NULL == tmp_subprocess.get()) { PLUGIN_PRINTF(("ServiceRuntime::Start (subprocess create failed)\n")); error_info->SetReport(ERROR_SEL_LDR_CREATE_LAUNCHER, diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.h b/ppapi/native_client/src/trusted/plugin/service_runtime.h index 7cd04bf..554942a 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.h +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.h @@ -247,7 +247,7 @@ class ServiceRuntime { Plugin* plugin_; bool should_report_uma_; nacl::ReverseService* reverse_service_; - nacl::scoped_ptr<nacl::SelLdrLauncher> subprocess_; + nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; nacl::WeakRefAnchor* anchor_; |