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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 $generator_warning
6
7 #include "mojo/monacl/mojo_syscall.h"
8
9 #include <stdio.h>
10
11 #include "mojo/monacl/mojo_syscall_internal.h"
12 #include "mojo/public/c/system/core.h"
13 #include "native_client/src/public/chrome_main.h"
14 #include "native_client/src/public/nacl_app.h"
15 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
16
17 namespace {
18
19 void MojoDescDestroy(void* handle) {
20 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.
21 }
22
23 ssize_t MojoDescSendMsg(void* handle,
24 const struct NaClImcTypedMsgHdr* msg,
25 int flags) {
26 UNREFERENCED_PARAMETER(flags);
27
28 struct NaClApp* nap = static_cast<struct NaClApp*>(handle);
29
30 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.
31 return -1;
32 }
33
34 uint32_t* params = static_cast<uint32_t*>(msg->iov[0].base);
35 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.
36
37 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.
38 switch (msgType) {
39 $body
40 default:
41 return -1;
42 }
43
44 return -1;
45 }
46
47 ssize_t MojoDescRecvMsg(void* handle,
48 struct NaClImcTypedMsgHdr* msg,
Mark Seaborn 2014/09/09 19:13:11 Fix indentation
Nick Bray (chromium) 2014/09/09 23:12:33 Done.
49 int flags) {
50 UNREFERENCED_PARAMETER(handle);
51 UNREFERENCED_PARAMETER(msg);
52 UNREFERENCED_PARAMETER(flags);
53
54 return -1;
55 }
56
57 struct NaClDesc* MakeMojoDesc(struct NaClApp* nap) {
58 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER;
59 funcs.Destroy = MojoDescDestroy;
60 funcs.SendMsg = MojoDescSendMsg;
61 funcs.RecvMsg = MojoDescRecvMsg;
62 return NaClDescMakeCustomDesc(nap, &funcs);
63 }
64
65 } // namespace
66
67 #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
68
69 void InjectMojo(struct NaClApp* nap) {
70 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698