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

Unified Diff: mojo/monacl/generator/mojo_syscall.cc.template

Issue 385983008: Mojo + NaCl prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GYP edit Created 6 years, 3 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: mojo/monacl/generator/mojo_syscall.cc.template
diff --git a/mojo/monacl/generator/mojo_syscall.cc.template b/mojo/monacl/generator/mojo_syscall.cc.template
new file mode 100644
index 0000000000000000000000000000000000000000..adfa3cb612822fd5538d56b78fc26a17f3dea42c
--- /dev/null
+++ b/mojo/monacl/generator/mojo_syscall.cc.template
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+$generator_warning
+
+#include "mojo/monacl/mojo_syscall.h"
+
+#include <stdio.h>
+
+#include "mojo/monacl/mojo_syscall_internal.h"
+#include "mojo/public/c/system/core.h"
+#include "native_client/src/public/chrome_main.h"
+#include "native_client/src/public/nacl_app.h"
+#include "native_client/src/trusted/desc/nacl_desc_custom.h"
+
+namespace {
+
+void MojoDescDestroy(void* handle) {
+ UNREFERENCED_PARAMETER(handle);
Mark Seaborn 2014/09/09 19:13:12 Not needed in Chromium-side code? Chromium doesn'
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
+}
+
+ssize_t MojoDescSendMsg(void* handle,
+ const struct NaClImcTypedMsgHdr* msg,
+ int flags) {
+ UNREFERENCED_PARAMETER(flags);
+
+ struct NaClApp* nap = static_cast<struct NaClApp*>(handle);
+
+ if (msg->iov_length != 1 || msg->iov[0].length < 8 || msg->ndesc_length != 0) {
Mark Seaborn 2014/09/09 19:13:11 Line is >80 chars
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
+ return -1;
+ }
+
+ uint32_t* params = static_cast<uint32_t*>(msg->iov[0].base);
+ uint32_t numParams = msg->iov[0].length / sizeof(*params);
Mark Seaborn 2014/09/09 19:13:12 "num_params"
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
+
+ uint32_t msgType = params[0];
Mark Seaborn 2014/09/09 19:13:12 "msg_type"
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
+ switch (msgType) {
+$body
+ default:
+ return -1;
+ }
+
+ return -1;
+}
+
+ssize_t MojoDescRecvMsg(void* handle,
+ struct NaClImcTypedMsgHdr* msg,
Mark Seaborn 2014/09/09 19:13:11 Fix indentation
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
+ int flags) {
+ UNREFERENCED_PARAMETER(handle);
+ UNREFERENCED_PARAMETER(msg);
+ UNREFERENCED_PARAMETER(flags);
+
+ return -1;
+}
+
+struct NaClDesc* MakeMojoDesc(struct NaClApp* nap) {
+ struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
+ funcs.Destroy = MojoDescDestroy;
+ funcs.SendMsg = MojoDescSendMsg;
+ funcs.RecvMsg = MojoDescRecvMsg;
+ return NaClDescMakeCustomDesc(nap, &funcs);
+}
+
+} // namespace
+
+#define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 2)
Mark Seaborn 2014/09/09 19:13:11 Nit: should this go in a header? It's duplicated
Nick Bray (chromium) 2014/09/09 23:12:33 Should it? Yes. It would be the only thing in a
+
+void InjectMojo(struct NaClApp* nap) {
+ NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
+}

Powered by Google App Engine
This is Rietveld 408576698