Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 1 | // Copyright 2013 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 | |
| 5 | // Multiply-included file, no traditional include guard. |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include "base/basictypes.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 10 | #include "base/process/process.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 11 | #include "build/build_config.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 12 | #include "components/nacl/common/nacl_types.h" |
| 13 | #include "components/nacl/common/pnacl_types.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 14 | #include "content/public/common/common_param_traits.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 15 | #include "ipc/ipc_channel_handle.h" |
| 16 | #include "ipc/ipc_message_macros.h" |
| 17 | #include "ipc/ipc_platform_file.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 18 | #include "url/gurl.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 19 | |
| 20 | #define IPC_MESSAGE_START NaClHostMsgStart |
| 21 | |
| 22 | IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams) |
| 23 | IPC_STRUCT_TRAITS_MEMBER(manifest_url) |
| 24 | IPC_STRUCT_TRAITS_MEMBER(render_view_id) |
| 25 | IPC_STRUCT_TRAITS_MEMBER(permission_bits) |
| 26 | IPC_STRUCT_TRAITS_MEMBER(uses_irt) |
| 27 | IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls) |
| 28 | IPC_STRUCT_TRAITS_MEMBER(enable_exception_handling) |
| 29 | IPC_STRUCT_TRAITS_END() |
| 30 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 31 | IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchResult) |
| 32 | IPC_STRUCT_TRAITS_MEMBER(imc_channel_handle) |
| 33 | IPC_STRUCT_TRAITS_MEMBER(ipc_channel_handle) |
| 34 | IPC_STRUCT_TRAITS_MEMBER(plugin_pid) |
| 35 | IPC_STRUCT_TRAITS_MEMBER(plugin_child_id) |
| 36 | IPC_STRUCT_TRAITS_END() |
| 37 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 38 | IPC_STRUCT_TRAITS_BEGIN(nacl::PnaclCacheInfo) |
| 39 | IPC_STRUCT_TRAITS_MEMBER(pexe_url) |
| 40 | IPC_STRUCT_TRAITS_MEMBER(abi_version) |
| 41 | IPC_STRUCT_TRAITS_MEMBER(opt_level) |
| 42 | IPC_STRUCT_TRAITS_MEMBER(last_modified) |
| 43 | IPC_STRUCT_TRAITS_MEMBER(etag) |
| 44 | IPC_STRUCT_TRAITS_END() |
| 45 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 46 | // A renderer sends this to the browser process when it wants to start |
| 47 | // a new instance of the Native Client process. The browser will launch |
| 48 | // the process and return an IPC channel handle. This handle will only |
| 49 | // be valid if the NaCl IPC proxy is enabled. |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 50 | IPC_SYNC_MESSAGE_CONTROL1_2(NaClHostMsg_LaunchNaCl, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 51 | nacl::NaClLaunchParams /* launch_params */, |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 52 | nacl::NaClLaunchResult /* launch_result */, |
| 53 | std::string /* error_message */) |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 54 | |
| 55 | // A renderer sends this to the browser process when it wants to |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 56 | // ensure that PNaCl is installed. |
| 57 | IPC_MESSAGE_CONTROL1(NaClHostMsg_EnsurePnaclInstalled, |
| 58 | int /* pp_instance */) |
| 59 | |
| 60 | // The browser replies to the renderer's request to ensure that |
| 61 | // PNaCl is installed. |
| 62 | IPC_MESSAGE_CONTROL2(NaClViewMsg_EnsurePnaclInstalledReply, |
| 63 | int /* pp_instance */, |
| 64 | bool /* success */) |
| 65 | |
| 66 | // A renderer sends this to the browser process when it wants to |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 67 | // open a file for from the Pnacl component directory. |
| 68 | IPC_SYNC_MESSAGE_CONTROL1_1(NaClHostMsg_GetReadonlyPnaclFD, |
| 69 | std::string /* name of requested PNaCl file */, |
| 70 | IPC::PlatformFileForTransit /* output file */) |
| 71 | |
| 72 | // A renderer sends this to the browser process when it wants to |
| 73 | // create a temporary file. |
| 74 | IPC_SYNC_MESSAGE_CONTROL0_1(NaClHostMsg_NaClCreateTemporaryFile, |
| 75 | IPC::PlatformFileForTransit /* out file */) |
| 76 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 77 | // A renderer sends this to the browser to request a file descriptor for |
| 78 | // a translated nexe. |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 79 | IPC_MESSAGE_CONTROL3(NaClHostMsg_NexeTempFileRequest, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 80 | int /* render_view_id */, |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 81 | int /* instance */, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 82 | nacl::PnaclCacheInfo /* cache info */) |
| 83 | |
| 84 | // The browser replies to a renderer's temp file request with output_file, |
| 85 | // which is either a writeable temp file to use for translation, or a |
| 86 | // read-only file containing the translated nexe from the cache. |
| 87 | IPC_MESSAGE_CONTROL3(NaClViewMsg_NexeTempFileReply, |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 88 | int /* instance */, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 89 | bool /* is_cache_hit */, |
| 90 | IPC::PlatformFileForTransit /* output file */) |
| 91 | |
| 92 | // A renderer sends this to the browser to report that its translation has |
| 93 | // finished and its temp file contains the translated nexe. |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 94 | IPC_MESSAGE_CONTROL2(NaClHostMsg_ReportTranslationFinished, |
| 95 | int /* instance */, |
| 96 | bool /* success */) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 97 | |
| 98 | // A renderer sends this to the browser process to report an error. |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 99 | IPC_MESSAGE_CONTROL2(NaClHostMsg_NaClErrorStatus, |
| 100 | int /* render_view_id */, |
| 101 | int /* Error ID */) |
| 102 | |
| 103 | // A renderer sends this to the browser process when it wants to |
| 104 | // open a NaCl executable file from an installed application directory. |
| 105 | IPC_SYNC_MESSAGE_CONTROL2_3(NaClHostMsg_OpenNaClExecutable, |
| 106 | int /* render_view_id */, |
| 107 | GURL /* URL of NaCl executable file */, |
| 108 | IPC::PlatformFileForTransit /* output file */, |
| 109 | uint64 /* file_token_lo */, |
| 110 | uint64 /* file_token_hi */) |