• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #if BUILDFLAG(IS_WIN)
62 // Tells the NaCl broker to launch a NaCl loader process.
63 IPC_MESSAGE_CONTROL2(NaClProcessMsg_LaunchLoaderThroughBroker,
64                      int, /* launch_id */
65                      mojo::MessagePipeHandle /* service_request_pipe */)
66 
67 // Notify the browser process that the loader was launched successfully.
68 IPC_MESSAGE_CONTROL2(NaClProcessMsg_LoaderLaunched,
69                      int, /* launch_id */
70                      base::ProcessHandle /* loader process handle */)
71 
72 // Tells the NaCl broker to attach a debug exception handler to the
73 // given NaCl loader process.
74 IPC_MESSAGE_CONTROL3(NaClProcessMsg_LaunchDebugExceptionHandler,
75                      int32_t /* pid of the NaCl process */,
76                      base::ProcessHandle /* handle of the NaCl process */,
77                      std::string /* NaCl internal process layout info */)
78 
79 // Notify the browser process that the broker process finished
80 // attaching a debug exception handler to the given NaCl loader
81 // process.
82 IPC_MESSAGE_CONTROL2(NaClProcessMsg_DebugExceptionHandlerLaunched,
83                      int32_t /* pid */,
84                      bool /* success */)
85 
86 // Notify the broker that all loader processes have been terminated and it
87 // should shutdown.
88 IPC_MESSAGE_CONTROL0(NaClProcessMsg_StopBroker)
89 
90 // Used by the NaCl process to request that a Windows debug exception
91 // handler be attached to it.
92 IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_AttachDebugExceptionHandler,
93                             std::string, /* Internal process info */
94                             bool /* Result */)
95 
96 // Notify the browser process that the NaCl process has bound the given
97 // TCP port number to use for the GDB debug stub.
98 IPC_MESSAGE_CONTROL1(NaClProcessHostMsg_DebugStubPortSelected,
99                      uint16_t /* debug_stub_port */)
100 #endif
101 
102 // Used by the NaCl process to query a database in the browser.  The database
103 // contains the signatures of previously validated code chunks.
104 IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_QueryKnownToValidate,
105                             std::string, /* A validation signature */
106                             bool /* Can validation be skipped? */)
107 
108 // Used by the NaCl process to add a validation signature to the validation
109 // database in the browser.
110 IPC_MESSAGE_CONTROL1(NaClProcessMsg_SetKnownToValidate,
111                      std::string /* A validation signature */)
112 
113 // Used by the NaCl process to acquire trusted information about a file directly
114 // from the browser, including the file's path as well as a fresh version of the
115 // file handle.
116 IPC_MESSAGE_CONTROL2(NaClProcessMsg_ResolveFileToken,
117                      uint64_t, /* file_token_lo */
118                      uint64_t /* file_token_hi */)
119 IPC_MESSAGE_CONTROL4(NaClProcessMsg_ResolveFileTokenReply,
120                      uint64_t,                    /* file_token_lo */
121                      uint64_t,                    /* file_token_hi */
122                      IPC::PlatformFileForTransit, /* fd */
123                      base::FilePath /* Path opened to get fd */)
124 
125 // Notify the browser process that the server side of the PPAPI channel was
126 // created successfully.
127 IPC_MESSAGE_CONTROL5(
128     NaClProcessHostMsg_PpapiChannelsCreated,
129     IPC::ChannelHandle, /* browser_channel_handle */
130     IPC::ChannelHandle, /* ppapi_renderer_channel_handle */
131     IPC::ChannelHandle, /* trusted_renderer_channel_handle */
132     IPC::ChannelHandle, /* manifest_service_channel_handle */
133     base::ReadOnlySharedMemoryRegion /* crash_info_shmem_region */)
134