Chromium Code Reviews| 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..37f2faa49fa3f8cfd8a15d411c54a04802eb46ac 100644 |
| --- a/components/nacl/loader/nonsfi/nonsfi_main.cc |
| +++ b/components/nacl/loader/nonsfi/nonsfi_main.cc |
| @@ -6,6 +6,8 @@ |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/synchronization/waitable_event.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,13 @@ 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); |
| + base::WaitableEvent event(true, false); |
| + ppapi::proxy::SetPpapiStartEvent(&event); |
| + // TODO: memory management. |
| + (new PluginMainThread(entry_point))->Start(); |
| + event.Wait(); |
|
Mark Seaborn
2014/02/07 22:53:43
This stuff with SetPpapiStartEvent() shouldn't be
|
| + if (done_cls) |
| + (*done_cls->Run)(done_cls); |
| } |
| const static struct NaClSrpcHandlerDesc kNonSfiServiceHandlers[] = { |
| @@ -142,6 +165,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(); |