[go: nahoru, domu]

blob: cce1c1d33bfb8759c25b28543771bfd13ef2f5b5 [file] [log] [blame]
hidehiko@chromium.org36ab6822014-04-09 12:13:051// 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
hidehikob0c306202014-10-30 01:51:095#include "build/build_config.h"
6
7// We need nacl_irt_start injection in SFI mode. Non-SFI has a different
8// start up procedure so we just exclude it.
9#if defined(OS_NACL_SFI)
10
avie029c4132015-12-23 06:45:2211#include <stdint.h>
12
hidehiko@chromium.org36ab6822014-04-09 12:13:0513#include "base/at_exit.h"
sammca6ae9622016-09-06 07:31:0414#include "mojo/edk/embedder/embedder.h"
hidehiko@chromium.org36ab6822014-04-09 12:13:0515#include "native_client/src/public/chrome_main.h"
16#include "native_client/src/public/irt_core.h"
mseaborn770b3282015-07-21 16:37:5717#include "ppapi/nacl_irt/irt_interfaces.h"
hidehiko@chromium.org36ab6822014-04-09 12:13:0518#include "ppapi/nacl_irt/plugin_startup.h"
19
amistrya6dcb652016-07-14 00:43:5920namespace {
sammc9bf370c2016-11-14 03:29:0821IPC::ChannelHandle MakeIPCHandle(int fd) {
22 return IPC::ChannelHandle(base::FileDescriptor(fd, false /* auto_close */));
amistrya6dcb652016-07-14 00:43:5923}
24} // namespace
25
hidehiko@chromium.org36ab6822014-04-09 12:13:0526void nacl_irt_start(uint32_t* info) {
27 nacl_irt_init(info);
28
29 // Though it isn't referenced here, we must instantiate an AtExitManager.
30 base::AtExitManager exit_manager;
31
32 // In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its
33 // successor, which is set in nacl_listener.cc.
sammc9bf370c2016-11-14 03:29:0834 ppapi::SetIPCChannelHandles(MakeIPCHandle(NACL_CHROME_DESC_BASE),
35 MakeIPCHandle(NACL_CHROME_DESC_BASE + 1),
36 MakeIPCHandle(NACL_CHROME_DESC_BASE + 2));
sammca6ae9622016-09-06 07:31:0437 // The Mojo EDK must be initialized before using IPC.
38 mojo::edk::Init();
hidehiko@chromium.org36ab6822014-04-09 12:13:0539 ppapi::StartUpPlugin();
40
41 nacl_irt_enter_user_code(info, chrome_irt_query);
42}
hidehikob0c306202014-10-30 01:51:0943
44#endif // defined(OS_NACL_SFI)