Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1930)

Unified Diff: components/nacl/loader/nonsfi/nonsfi_main.cc

Issue 140573003: Connect PPAPI IPC channels for non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..993481d1e942dc9d6b2ed3a2e018e4d90b1d8fe4 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,40 @@
#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/proxy/plugin_main_irt.h"
namespace nacl {
namespace nonsfi {
namespace {
+typedef void (*EntryPointType)(uintptr_t *);
+
+class PluginMainThread : public base::SimpleThread {
+ public:
+ explicit PluginMainThread(EntryPointType 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.
+ };
+ entry_point_(info);
+ }
+
+ private:
+ EntryPointType entry_point_;
+};
+
struct NaClDescUnrefer {
void operator()(struct NaClDesc* desc) const {
NaClDescUnref(desc);
@@ -49,19 +80,18 @@ 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
Mark Seaborn 2014/02/15 03:00:52 Do you mean the SimpleThread pointer?
hidehiko 2014/02/19 13:05:02 Acknowledged.
+ // initialization message passing between the renderer from SRPC to IPC.
+ base::SimpleThread* thread =
+ new PluginMainThread(reinterpret_cast<EntryPointType>(entry_point));
+ ANNOTATE_LEAKING_OBJECT_PTR(thread);
Mark Seaborn 2014/02/15 03:00:52 Maybe use base::PlatformThread::CreateNonJoinable(
hidehiko 2014/02/19 13:05:02 Great to know. Done.
+ thread->Start();
+
+ if (done_cls)
Mark Seaborn 2014/02/15 03:00:52 I don't think you need a NULL check here
hidehiko 2014/02/19 13:05:02 Done.
+ (*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) {
+ ::SetIPCFileDescriptors(browser_ipc_fd, renderer_ipc_fd);
+}
+
void MainStart(NaClHandle imc_bootstrap_handle) {
NaClSrpcModuleInit();

Powered by Google App Engine
This is Rietveld 408576698