xref: /aosp_15_r20/external/cronet/components/nacl/common/nacl_messages.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Defines messages between the browser and NaCl process.
6 
7 // no-include-guard-because-multiply-included
8 // Multiply-included message file, no traditional include guard.
9 
10 #include <stdint.h>
11 
12 #include "base/memory/read_only_shared_memory_region.h"
13 #include "base/process/process.h"
14 #include "build/build_config.h"
15 #include "components/nacl/common/nacl_types.h"
16 #include "components/nacl/common/nacl_types_param_traits.h"
17 #include "ipc/ipc_channel_handle.h"
18 #include "ipc/ipc_message_macros.h"
19 #include "ipc/ipc_message_start.h"
20 #include "ipc/ipc_mojo_param_traits.h"
21 #include "ipc/ipc_platform_file.h"
22 #include "mojo/public/cpp/system/message_pipe.h"
23 
24 #define IPC_MESSAGE_START NaClMsgStart
25 
26 IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams)
27   IPC_STRUCT_TRAITS_MEMBER(nexe_file)
28   IPC_STRUCT_TRAITS_MEMBER(nexe_file_path_metadata)
29   IPC_STRUCT_TRAITS_MEMBER(irt_handle)
30 #if BUILDFLAG(IS_POSIX)
31   IPC_STRUCT_TRAITS_MEMBER(debug_stub_server_bound_socket)
32 #endif
33   IPC_STRUCT_TRAITS_MEMBER(validation_cache_enabled)
34   IPC_STRUCT_TRAITS_MEMBER(validation_cache_key)
35   IPC_STRUCT_TRAITS_MEMBER(version)
36   IPC_STRUCT_TRAITS_MEMBER(enable_debug_stub)
37   IPC_STRUCT_TRAITS_MEMBER(process_type)
38   IPC_STRUCT_TRAITS_MEMBER(crash_info_shmem_region)
39 IPC_STRUCT_TRAITS_END()
40 
41 IPC_STRUCT_TRAITS_BEGIN(nacl::NaClResourcePrefetchResult)
42   IPC_STRUCT_TRAITS_MEMBER(file)
43   IPC_STRUCT_TRAITS_MEMBER(file_path_metadata)
44   IPC_STRUCT_TRAITS_MEMBER(file_key)
45 IPC_STRUCT_TRAITS_END()
46 
47 //-----------------------------------------------------------------------------
48 // NaClProcess messages
49 // These are messages sent between the browser and the NaCl process.
50 
51 // Sends a prefetched resource file to a NaCl loader process. This message
52 // can be sent multiple times, but all of them must be done before sending
53 // NaClProcessMsg_Start.
54 IPC_MESSAGE_CONTROL1(NaClProcessMsg_AddPrefetchedResource,
55                      nacl::NaClResourcePrefetchResult)
56 
57 // Tells the NaCl process to start. This message can be sent only once.
58 IPC_MESSAGE_CONTROL1(NaClProcessMsg_Start,
59                      nacl::NaClStartParams /* params */)
60 
61 // Used by the NaCl process to query a database in the browser.  The database
62 // contains the signatures of previously validated code chunks.
63 IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_QueryKnownToValidate,
64                             std::string, /* A validation signature */
65                             bool /* Can validation be skipped? */)
66 
67 // Used by the NaCl process to add a validation signature to the validation
68 // database in the browser.
69 IPC_MESSAGE_CONTROL1(NaClProcessMsg_SetKnownToValidate,
70                      std::string /* A validation signature */)
71 
72 // Used by the NaCl process to acquire trusted information about a file directly
73 // from the browser, including the file's path as well as a fresh version of the
74 // file handle.
75 IPC_MESSAGE_CONTROL2(NaClProcessMsg_ResolveFileToken,
76                      uint64_t, /* file_token_lo */
77                      uint64_t /* file_token_hi */)
78 IPC_MESSAGE_CONTROL4(NaClProcessMsg_ResolveFileTokenReply,
79                      uint64_t,                    /* file_token_lo */
80                      uint64_t,                    /* file_token_hi */
81                      IPC::PlatformFileForTransit, /* fd */
82                      base::FilePath /* Path opened to get fd */)
83 
84 // Notify the browser process that the server side of the PPAPI channel was
85 // created successfully.
86 IPC_MESSAGE_CONTROL5(
87     NaClProcessHostMsg_PpapiChannelsCreated,
88     IPC::ChannelHandle, /* browser_channel_handle */
89     IPC::ChannelHandle, /* ppapi_renderer_channel_handle */
90     IPC::ChannelHandle, /* trusted_renderer_channel_handle */
91     IPC::ChannelHandle, /* manifest_service_channel_handle */
92     base::ReadOnlySharedMemoryRegion /* crash_info_shmem_region */)
93