Chromium Code Reviews| Index: mojo/nacl/mojo_interface_nacl_nonsfi.cc |
| diff --git a/mojo/nacl/monacl_shell_nonsfi.cc b/mojo/nacl/mojo_interface_nacl_nonsfi.cc |
| similarity index 52% |
| copy from mojo/nacl/monacl_shell_nonsfi.cc |
| copy to mojo/nacl/mojo_interface_nacl_nonsfi.cc |
| index 3bacf9642812107f66112334aa507b69553ae4e2..fe207fe6382643d3d63160426bf41d970e0bd41f 100644 |
| --- a/mojo/nacl/monacl_shell_nonsfi.cc |
| +++ b/mojo/nacl/mojo_interface_nacl_nonsfi.cc |
| @@ -2,17 +2,24 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include <fcntl.h> |
| -#include <iostream> |
| - |
| -#include "mojo/edk/embedder/embedder.h" |
| -#include "mojo/edk/embedder/simple_platform_support.h" |
| -#include "mojo/public/platform/nacl/mojo_irt.h" |
| -#include "native_client/src/public/irt_core.h" |
| -#include "native_client/src/public/nonsfi/elf_loader.h" |
| +#include "mojo_interface_nacl_nonsfi.h" |
| namespace { |
| +MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; |
|
Sean Klein
2015/09/01 20:24:48
Is there potentially an issue with having a single
Mark Seaborn
2015/09/01 21:05:46
Yes. We don't really want to run multiple nexes i
Sean Klein
2015/09/01 22:55:27
Acknowledged.
|
| + |
| +MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
| + // TODO(smklein): Test this handle |
|
Mark Seaborn
2015/09/01 21:05:46
Nit: I would avoid TODOs where the TODO would be a
Sean Klein
2015/09/01 22:55:26
Done.
|
| + *handle = g_mojo_handle; |
| + return MOJO_RESULT_OK; |
| +} |
| + |
| +} // namespace |
| + |
| +void mojo_set_initial_handle(MojoHandle handle) { |
| + g_mojo_handle = handle; |
| +} |
| + |
| const struct nacl_irt_mojo kIrtMojo = { |
| MojoCreateSharedBuffer, |
| MojoDuplicateBufferHandle, |
| @@ -32,7 +39,7 @@ const struct nacl_irt_mojo kIrtMojo = { |
| MojoCreateMessagePipe, |
| MojoWriteMessage, |
| MojoReadMessage, |
| - nullptr, // TODO(smklein): Add _MojoGetInitialHandle. |
| + _MojoGetInitialHandle, |
| }; |
| const struct nacl_irt_interface kIrtInterfaces[] = { |
| @@ -50,28 +57,3 @@ size_t mojo_irt_nonsfi_query(const char* interface_ident, |
| return result; |
| return nacl_irt_query_core(interface_ident, table, tablesize); |
| } |
| - |
| -} // namespace |
| - |
| -int main(int argc, char** argv, char** environ) { |
| - nacl_irt_nonsfi_allow_dev_interfaces(); |
| - if (argc < 2) { |
| - std::cerr << "Usage: " << argv[0] << " <executable> <args...>\n"; |
| - return 1; |
| - } |
| - const char* nexe_filename = argv[1]; |
| - int fd = open(nexe_filename, O_RDONLY); |
| - if (fd < 0) { |
| - std::cerr << "Failed to open " << nexe_filename << ": " << |
| - strerror(errno) << "\n"; |
| - return 1; |
| - } |
| - uintptr_t entry = NaClLoadElfFile(fd); |
| - |
| - mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
| - new mojo::embedder::SimplePlatformSupport())); |
| - |
| - return nacl_irt_nonsfi_entry(argc - 1, argv + 1, environ, |
| - reinterpret_cast<nacl_entry_func_t>(entry), |
| - mojo_irt_nonsfi_query); |
| -} |