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

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..1179d7448512a5d9a5c329a353549622d8f7c8b5 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/platform_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"
@@ -22,6 +24,41 @@ namespace nacl {
namespace nonsfi {
namespace {
+typedef void (*EntryPointType)(uintptr_t *);
Mark Seaborn 2014/02/19 17:00:30 Nit: "uintptr_t*" (to follow Chrome spacing style)
hidehiko 2014/02/20 18:50:01 Done.
+
+class PluginMainDelegate : public base::PlatformThread::Delegate {
+ public:
+ explicit PluginMainDelegate(EntryPointType entry_point)
+ : entry_point_(entry_point) {
+ }
+
+ virtual ~PluginMainDelegate() {
+ }
+
+ virtual void ThreadMain() OVERRIDE {
+ base::PlatformThread::SetName("NaClMainThread");
+
+ 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_;
+};
+
+// Default stack size of the plugin main thread. We heuristically chose 1M.
+const size_t kStackSize = 1024 * 1024;
Mark Seaborn 2014/02/19 17:00:30 NaCl uses 16MB for the initial stack size (see NAC
hidehiko 2014/02/20 18:50:01 Good to know. Done.
+
struct NaClDescUnrefer {
void operator()(struct NaClDesc* desc) const {
NaClDescUnref(desc);
@@ -46,22 +83,16 @@ void LoadModuleRpc(struct NaClSrpcRpc* rpc,
return;
}
- uintptr_t entry_point = image.entry_point();
- rpc->result = NACL_SRPC_RESULT_OK;
+ EntryPointType entry_point =
+ reinterpret_cast<EntryPointType>(image.entry_point());
+ if (!base::PlatformThread::CreateNonJoinable(
+ kStackSize, new PluginMainDelegate(entry_point))) {
+ LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread.";
+ return;
+ }
- // 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);
+ rpc->result = NACL_SRPC_RESULT_OK;
+ (*done_cls->Run)(done_cls);
}
const static struct NaClSrpcHandlerDesc kNonSfiServiceHandlers[] = {

Powered by Google App Engine
This is Rietveld 408576698