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

Unified Diff: native_client_sdk/src/libraries/ppapi_simple/ps_main.cc

Issue 412083002: [NaCl SDK] Allow ppapi_simple executables to run in both sel_ldr and in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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: native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc b/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
index eabbeaace6fb150f0c112a1f5241de68f231d858..167ff1cc95f2db1782f316291cfc94cd78c211d8 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
@@ -2,15 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifdef __native_client__
+#include <irt.h>
+#include <irt_ppapi.h>
+#endif
+
+#include <stdio.h>
+
+#include "nacl_io/nacl_io.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
-
#include "ppapi_simple/ps_instance.h"
#include "ppapi_simple/ps_main.h"
+extern "C" int PpapiPluginMain();
-void* PSMainCreate(PP_Instance inst, PSMainFunc_t func) {
+void* PSMainCreate(PP_Instance inst) {
PSInstance* pInst = new PSInstance(inst);
- pInst->SetMain(func);
+ pInst->SetMain(PSUserMainGet());
return pInst;
}
+
+/**
+ * main entry point for ppapi_simple applications. This differs from the
+ * regular ppapi main entry point in that it will fall back to running
+ * the user's main code in the case that the PPAPI hooks are not found.
+ * This allows ppapi_simple binary to run within chrome (with PPAPI present)
+ * and also under sel_ldr (no PPAPI).
+ */
+int main(int argc, char* argv[]) {
+#ifdef __native_client__
+ struct nacl_irt_ppapihook hooks;
+ if (nacl_interface_query(NACL_IRT_PPAPIHOOK_v0_1, &hooks, sizeof(hooks)) ==
+ sizeof(hooks)) {
+ return PpapiPluginMain();
+ }
+#endif
+ // By default, or if not running in the browser we simply run the main
+ // entry point directly, on the main thread.
+ nacl_io_init();
+ return PSUserMainGet()(argc, argv);
+}

Powered by Google App Engine
This is Rietveld 408576698