OLD | NEW |
---|---|
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/system_impl_private.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 MojoSystemImpl g_mojo_system = 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 Loading... | |
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_system = MojoSystemImplCreateImpl(); |
104 // TODO(ncbray): handle errors? | |
viettrungluu
2015/04/06 23:21:02
I'd just CHECK (or equivalent -- I don't know what
Nick Bray (chromium)
2015/04/07 23:51:05
Done.
| |
105 MojoSystemImplTransferHandle(MojoSystemImplGetDefaultImpl(), handle, g_mojo_sy stem, | |
Nick Bray (chromium)
2015/04/06 22:51:00
Line length, I know, will fix in next upload.
| |
106 &g_mojo_handle); | |
107 } | 107 } |
108 | 108 |
109 void InjectDisabledMojo(struct NaClApp* nap) { | 109 void InjectDisabledMojo(struct NaClApp* nap) { |
110 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap)); | 110 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap)); |
111 } | 111 } |
OLD | NEW |