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

Unified Diff: src/trusted/service_runtime/sel_main_chrome.c

Issue 1089323006: Add a load_status callback hook that is invoked at the end of chrome LoadApp. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: reorder events Created 5 years, 8 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
« src/public/chrome_main.h ('K') | « src/public/chrome_main.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/sel_main_chrome.c
diff --git a/src/trusted/service_runtime/sel_main_chrome.c b/src/trusted/service_runtime/sel_main_chrome.c
index c4a013e802cdde0a7cab5e50c098101ee0fa0ff3..4129ff63bda588514f800ea40189d971538a5da4 100644
--- a/src/trusted/service_runtime/sel_main_chrome.c
+++ b/src/trusted/service_runtime/sel_main_chrome.c
@@ -44,6 +44,7 @@
static int g_initialized = 0;
static void (*g_fatal_error_handler)(const char *data, size_t bytes) = NULL;
+static void (*g_load_status_callback)(int load_status) = NULL;
static const int default_argc = 1;
static const char *const default_argv[1] = {"NaClMain"};
@@ -76,6 +77,13 @@ void NaClSetFatalErrorCallback(void (*func)(const char *data, size_t bytes)) {
NaClErrorLogHookInit(NaClFatalErrorHandlerCallback, NULL);
}
+void NaClSetLoadStatusCallback(void (*func)(int load_status)) {
+ CHECK(g_initialized);
+ if (g_load_status_callback != NULL)
+ NaClLog(LOG_FATAL, "NaClSetLoadStatusCallback called twice.\n");
+ g_load_status_callback = func;
+}
+
struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) {
struct NaClChromeMainArgs *args;
@@ -371,17 +379,35 @@ static int LoadApp(struct NaClApp *nap, struct NaClChromeMainArgs *args) {
#endif
}
+ if (g_load_status_callback != NULL) {
+ g_load_status_callback(LOAD_OK);
+ }
return LOAD_OK;
done:
fflush(stdout);
/*
- * If there is a secure command channel, we sent an RPC reply with
- * the reason that the nexe was rejected. If we exit now, that
- * reply may still be in-flight and the various channel closure (esp
- * reverse channel) may be detected first. This would result in a
- * crash being reported, rather than the error in the RPC reply.
+ * If there is a load_status_callback, call that now. TODO(jvoung): remove
+ * NaClBlockIfCommandChannelExists() and just call g_load_status_callback
+ * to indicate the load_status.
+ */
+ if (g_load_status_callback != NULL) {
+ /* Don't return LOAD_OK if we had some failure loading. */
+ if (LOAD_OK == errcode) {
+ errcode = LOAD_INTERNAL;
+ }
+ g_load_status_callback(errcode);
+ NaClLog(LOG_ERROR, "reap logs\n");
+ NaClLogRunAbortBehavior();
+ return errcode;
+ }
+ /*
+ * If there is no load_status_callback, but there is a secure command channel,
+ * we sent an RPC reply with the reason that the nexe was rejected.
+ * If we exit now, that reply may still be in-flight and the various
+ * channel closure (esp reverse channel) may be detected first. This would
+ * result in a crash being reported, rather than the error in the RPC reply.
* Instead, we wait for the hard-shutdown on the command channel.
*/
if (LOAD_OK != errcode) {
« src/public/chrome_main.h ('K') | « src/public/chrome_main.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698