| 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 // We need nacl_irt_start injection in SFI mode. Non-SFI has a different | 7 // We need nacl_irt_start injection in SFI mode. Non-SFI has a different |
| 8 // start up procedure so we just exclude it. | 8 // start up procedure so we just exclude it. |
| 9 #if defined(OS_NACL_SFI) | 9 #if defined(OS_NACL_SFI) |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
| 14 #include "mojo/edk/embedder/embedder.h" | 14 #include "mojo/edk/embedder/embedder.h" |
| 15 #include "native_client/src/public/chrome_main.h" | 15 #include "native_client/src/public/chrome_main.h" |
| 16 #include "native_client/src/public/irt_core.h" | 16 #include "native_client/src/public/irt_core.h" |
| 17 #include "ppapi/nacl_irt/irt_interfaces.h" | 17 #include "ppapi/nacl_irt/irt_interfaces.h" |
| 18 #include "ppapi/nacl_irt/plugin_startup.h" | 18 #include "ppapi/nacl_irt/plugin_startup.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 IPC::ChannelHandle MakeIPCHandle(const char* name, int fd) { | 21 IPC::ChannelHandle MakeIPCHandle(int fd) { |
| 22 return IPC::ChannelHandle(name, | 22 return IPC::ChannelHandle(base::FileDescriptor(fd, false /* auto_close */)); |
| 23 base::FileDescriptor(fd, false /* auto_close */)); | |
| 24 } | 23 } |
| 25 } // namespace | 24 } // namespace |
| 26 | 25 |
| 27 void nacl_irt_start(uint32_t* info) { | 26 void nacl_irt_start(uint32_t* info) { |
| 28 nacl_irt_init(info); | 27 nacl_irt_init(info); |
| 29 | 28 |
| 30 // Though it isn't referenced here, we must instantiate an AtExitManager. | 29 // Though it isn't referenced here, we must instantiate an AtExitManager. |
| 31 base::AtExitManager exit_manager; | 30 base::AtExitManager exit_manager; |
| 32 | 31 |
| 33 // In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its | 32 // In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its |
| 34 // successor, which is set in nacl_listener.cc. | 33 // successor, which is set in nacl_listener.cc. |
| 35 ppapi::SetIPCChannelHandles( | 34 ppapi::SetIPCChannelHandles(MakeIPCHandle(NACL_CHROME_DESC_BASE), |
| 36 MakeIPCHandle("NaCl Browser", NACL_CHROME_DESC_BASE), | 35 MakeIPCHandle(NACL_CHROME_DESC_BASE + 1), |
| 37 MakeIPCHandle("NaCl Renderer", NACL_CHROME_DESC_BASE + 1), | 36 MakeIPCHandle(NACL_CHROME_DESC_BASE + 2)); |
| 38 MakeIPCHandle("NaCl Manifest", NACL_CHROME_DESC_BASE + 2)); | |
| 39 // The Mojo EDK must be initialized before using IPC. | 37 // The Mojo EDK must be initialized before using IPC. |
| 40 mojo::edk::Init(); | 38 mojo::edk::Init(); |
| 41 ppapi::StartUpPlugin(); | 39 ppapi::StartUpPlugin(); |
| 42 | 40 |
| 43 nacl_irt_enter_user_code(info, chrome_irt_query); | 41 nacl_irt_enter_user_code(info, chrome_irt_query); |
| 44 } | 42 } |
| 45 | 43 |
| 46 #endif // defined(OS_NACL_SFI) | 44 #endif // defined(OS_NACL_SFI) |
| OLD | NEW |