Avi Drissman | db497b3 | 2022-09-15 19:47:28 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 5 | #include <stdint.h> |
| 6 | |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 7 | #include "base/at_exit.h" |
Ken Rockot | f03d97c95 | 2018-07-04 22:08:10 | [diff] [blame] | 8 | #include "mojo/core/embedder/embedder.h" |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 9 | #include "native_client/src/public/chrome_main.h" |
| 10 | #include "native_client/src/public/irt_core.h" |
mseaborn | 770b328 | 2015-07-21 16:37:57 | [diff] [blame] | 11 | #include "ppapi/nacl_irt/irt_interfaces.h" |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 12 | #include "ppapi/nacl_irt/plugin_startup.h" |
| 13 | |
amistry | a6dcb65 | 2016-07-14 00:43:59 | [diff] [blame] | 14 | namespace { |
sammc | 9bf370c | 2016-11-14 03:29:08 | [diff] [blame] | 15 | IPC::ChannelHandle MakeIPCHandle(int fd) { |
| 16 | return IPC::ChannelHandle(base::FileDescriptor(fd, false /* auto_close */)); |
amistry | a6dcb65 | 2016-07-14 00:43:59 | [diff] [blame] | 17 | } |
| 18 | } // namespace |
| 19 | |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 20 | void nacl_irt_start(uint32_t* info) { |
| 21 | nacl_irt_init(info); |
| 22 | |
| 23 | // Though it isn't referenced here, we must instantiate an AtExitManager. |
| 24 | base::AtExitManager exit_manager; |
| 25 | |
| 26 | // In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its |
| 27 | // successor, which is set in nacl_listener.cc. |
sammc | 9bf370c | 2016-11-14 03:29:08 | [diff] [blame] | 28 | ppapi::SetIPCChannelHandles(MakeIPCHandle(NACL_CHROME_DESC_BASE), |
| 29 | MakeIPCHandle(NACL_CHROME_DESC_BASE + 1), |
| 30 | MakeIPCHandle(NACL_CHROME_DESC_BASE + 2)); |
sammc | a6ae962 | 2016-09-06 07:31:04 | [diff] [blame] | 31 | // The Mojo EDK must be initialized before using IPC. |
Ken Rockot | f03d97c95 | 2018-07-04 22:08:10 | [diff] [blame] | 32 | mojo::core::Init(); |
hidehiko@chromium.org | 36ab682 | 2014-04-09 12:13:05 | [diff] [blame] | 33 | ppapi::StartUpPlugin(); |
| 34 | |
| 35 | nacl_irt_enter_user_code(info, chrome_irt_query); |
| 36 | } |