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

Side by Side Diff: nacl_bindings_generator/mojo_syscall.cc.tmpl

Issue 1052723003: NaCl: create a separate namespace for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 {{generator_warning}} 5 {{generator_warning}}
6 6
7 #include "{{bindings_dir}}/mojo_syscall.h" 7 #include "{{bindings_dir}}/mojo_syscall.h"
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 10
11 #include "mojo/public/c/system/core.h"
12 #include "mojo/public/platform/native/core_system_api.h"
11 #include "{{bindings_dir}}/mojo_syscall_internal.h" 13 #include "{{bindings_dir}}/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/chrome_main.h"
14 #include "native_client/src/public/nacl_app.h" 15 #include "native_client/src/public/nacl_app.h"
15 #include "native_client/src/trusted/desc/nacl_desc_custom.h" 16 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
16 17
17 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; 18 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID;
19 MojoCoreHandle g_mojo_core = nullptr;
18 20
19 namespace { 21 namespace {
20 22
21 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { 23 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
22 *handle = g_mojo_handle; 24 *handle = g_mojo_handle;
23 return MOJO_RESULT_OK; 25 return MOJO_RESULT_OK;
24 } 26 }
25 27
26 void MojoDescDestroy(void* handle) { 28 void MojoDescDestroy(void* handle) {
27 } 29 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return NaClDescMakeCustomDesc(nap, &funcs); 91 return NaClDescMakeCustomDesc(nap, &funcs);
90 } 92 }
91 93
92 } // namespace 94 } // namespace
93 95
94 // The value for this FD must not conflict with uses inside Chromium. However, 96 // The value for this FD must not conflict with uses inside Chromium. However,
95 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define 97 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define
96 // from there. 98 // from there.
97 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3) 99 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3)
98 100
99 void InjectMojo(struct NaClApp* nap) {
100 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
101 g_mojo_handle = MOJO_HANDLE_INVALID;
102 }
103
104 void InjectMojo(struct NaClApp* nap, MojoHandle handle) { 101 void InjectMojo(struct NaClApp* nap, MojoHandle handle) {
105 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap)); 102 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
106 g_mojo_handle = handle; 103 g_mojo_core = MojoCoreCreateCore();
104 // TODO handle errors?
viettrungluu 2015/04/01 23:36:19 nit: "TODO(ncbray):"
Nick Bray (chromium) 2015/04/04 00:09:09 Done.
105 MojoCoreTransferHandle(MojoCoreGetDefaultCore(), handle, g_mojo_core, &g_mojo_ handle);
viettrungluu 2015/04/01 23:36:19 80 cols
Nick Bray (chromium) 2015/04/04 00:09:09 Done.
107 } 106 }
108 107
109 void InjectDisabledMojo(struct NaClApp* nap) { 108 void InjectDisabledMojo(struct NaClApp* nap) {
110 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap)); 109 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap));
111 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698