| Index: components/nacl/loader/nonsfi/nonsfi_main.cc
|
| diff --git a/components/nacl/loader/nonsfi/nonsfi_main.cc b/components/nacl/loader/nonsfi/nonsfi_main.cc
|
| index d9847c528a18d1758deb79d28db629b155ef59e0..ddec3f7fa0e6869e88f03b106b9d28347424f435 100644
|
| --- a/components/nacl/loader/nonsfi/nonsfi_main.cc
|
| +++ b/components/nacl/loader/nonsfi/nonsfi_main.cc
|
| @@ -4,8 +4,10 @@
|
|
|
| #include "components/nacl/loader/nonsfi/nonsfi_main.h"
|
|
|
| +#include "base/debug/leak_annotations.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/threading/simple_thread.h"
|
| #include "components/nacl/loader/nonsfi/elf_loader.h"
|
| #include "components/nacl/loader/nonsfi/irt_interfaces.h"
|
| #include "native_client/src/include/elf_auxv.h"
|
| @@ -17,11 +19,38 @@
|
| #include "native_client/src/trusted/desc/nrd_all_modules.h"
|
| #include "native_client/src/trusted/desc/nrd_xfer.h"
|
| #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
|
| +#include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h"
|
|
|
| namespace nacl {
|
| namespace nonsfi {
|
| namespace {
|
|
|
| +class PluginMainThread : public base::SimpleThread {
|
| + public:
|
| + PluginMainThread(uintptr_t entry_point)
|
| + : base::SimpleThread("NaClMainThread"),
|
| + entry_point_(entry_point) {
|
| + }
|
| +
|
| + virtual void Run() OVERRIDE {
|
| + uintptr_t info[] = {
|
| + 0, // Do not use fini.
|
| + 0, // envc.
|
| + 0, // argc.
|
| + 0, // Null terminate for argv.
|
| + 0, // Null terminate for envv.
|
| + AT_SYSINFO,
|
| + reinterpret_cast<uintptr_t>(&NaClIrtInterface),
|
| + AT_NULL,
|
| + 0, // Null terminate for auxv.
|
| + };
|
| + reinterpret_cast<void (*)(uintptr_t*)>(entry_point_)(info);
|
| + }
|
| +
|
| + private:
|
| + uintptr_t entry_point_;
|
| +};
|
| +
|
| struct NaClDescUnrefer {
|
| void operator()(struct NaClDesc* desc) const {
|
| NaClDescUnref(desc);
|
| @@ -49,19 +78,20 @@ void LoadModuleRpc(struct NaClSrpcRpc* rpc,
|
| uintptr_t entry_point = image.entry_point();
|
| rpc->result = NACL_SRPC_RESULT_OK;
|
|
|
| - // Run for testing. TODO(hidehiko): Remove this.
|
| - uintptr_t info[] = {
|
| - 0, // Do not use fini.
|
| - 0, // envc.
|
| - 0, // argc.
|
| - 0, // Null terminate for argv.
|
| - 0, // Null terminate for envv.
|
| - AT_SYSINFO,
|
| - reinterpret_cast<uintptr_t>(&NaClIrtInterface),
|
| - AT_NULL,
|
| - 0, // Null terminate for auxv.
|
| - };
|
| - reinterpret_cast<void (*)(uintptr_t*)>(entry_point)(info);
|
| + // We intentionally leak the thread. The plugin runs on the thread, and once
|
| + // it is completed, this process should be killed so that the memory for
|
| + // the thread is also collected correctly.
|
| + // We may want to manage the thread pointer after we switch the
|
| + // initialization message passing between the renderer from SRPC to IPC.
|
| + base::SimpleThread* thread = new PluginMainThread(entry_point);
|
| + ANNOTATE_LEAKING_OBJECT_PTR(thread);
|
| + thread->Start();
|
| +
|
| + // Wait until the ppapi set up is completed on the main thread.
|
| + ppapi::proxy::WaitForPpapiStartEvent();
|
| +
|
| + if (done_cls)
|
| + (*done_cls->Run)(done_cls);
|
| }
|
|
|
| const static struct NaClSrpcHandlerDesc kNonSfiServiceHandlers[] = {
|
| @@ -142,6 +172,10 @@ void ServiceAccept(struct NaClDesc* port) {
|
|
|
| } // namespace
|
|
|
| +void SetIPCFileDescriptors(int browser_ipc_fd, int renderer_ipc_fd) {
|
| + ppapi::proxy::SetIPCFileDescriptors(browser_ipc_fd, renderer_ipc_fd);
|
| +}
|
| +
|
| void MainStart(NaClHandle imc_bootstrap_handle) {
|
| NaClSrpcModuleInit();
|
|
|
|
|