[go: nahoru, domu]

blob: d25a6ab5eb1f428ba5464fa320f5d9b8dbb38244 [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 {
21IPC::ChannelHandle MakeIPCHandle(const char* name, int fd) {
22 return IPC::ChannelHandle(name,
23 base::FileDescriptor(fd, false /* auto_close */));
24}
25} // namespace
26
hidehiko@chromium.org36ab6822014-04-09 12:13:0527void nacl_irt_start(uint32_t* info) {
28 nacl_irt_init(info);
29
30 // Though it isn't referenced here, we must instantiate an AtExitManager.
31 base::AtExitManager exit_manager;
32
33 // In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its
34 // successor, which is set in nacl_listener.cc.
amistrya6dcb652016-07-14 00:43:5935 ppapi::SetIPCChannelHandles(
36 MakeIPCHandle("NaCl Browser", NACL_CHROME_DESC_BASE),
37 MakeIPCHandle("NaCl Renderer", NACL_CHROME_DESC_BASE + 1),
38 MakeIPCHandle("NaCl Manifest", NACL_CHROME_DESC_BASE + 2));
sammca6ae9622016-09-06 07:31:0439 // The Mojo EDK must be initialized before using IPC.
40 mojo::edk::Init();
hidehiko@chromium.org36ab6822014-04-09 12:13:0541 ppapi::StartUpPlugin();
42
43 nacl_irt_enter_user_code(info, chrome_irt_query);
44}
hidehikob0c306202014-10-30 01:51:0945
46#endif // defined(OS_NACL_SFI)