1a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch// Copyright 2013 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Defines messages between the browser and NaCl process.
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Multiply-included message file, no traditional include guard.
8a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "base/process/process.h"
9a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "components/nacl/common/nacl_types.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_channel_handle.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_message_macros.h"
1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ipc/ipc_platform_file.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_START NaClMsgStart
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams)
17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  IPC_STRUCT_TRAITS_MEMBER(nexe_file)
185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(nexe_token_lo)
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(nexe_token_hi)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(handles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(debug_stub_server_bound_socket)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(validation_cache_enabled)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(validation_cache_key)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(version)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(enable_exception_handling)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(enable_debug_stub)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(enable_ipc_proxy)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(uses_irt)
29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls)
3003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  IPC_STRUCT_TRAITS_MEMBER(crash_info_shmem_handle)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END()
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//-----------------------------------------------------------------------------
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// NaClProcess messages
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// These are messages sent between the browser and the NaCl process.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the NaCl process to start.
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(NaClProcessMsg_Start,
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     nacl::NaClStartParams /* params */)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the NaCl broker to launch a NaCl loader process.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(NaClProcessMsg_LaunchLoaderThroughBroker,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     std::string /* channel ID for the loader */)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notify the browser process that the loader was launched successfully.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL2(NaClProcessMsg_LoaderLaunched,
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     std::string,  /* channel ID for the loader */
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     base::ProcessHandle /* loader process handle */)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tells the NaCl broker to attach a debug exception handler to the
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// given NaCl loader process.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL3(NaClProcessMsg_LaunchDebugExceptionHandler,
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int32 /* pid of the NaCl process */,
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     base::ProcessHandle /* handle of the NaCl process */,
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     std::string /* NaCl internal process layout info */)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notify the browser process that the broker process finished
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// attaching a debug exception handler to the given NaCl loader
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// process.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL2(NaClProcessMsg_DebugExceptionHandlerLaunched,
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int32 /* pid */,
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     bool /* success */)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notify the broker that all loader processes have been terminated and it
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// should shutdown.
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL0(NaClProcessMsg_StopBroker)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used by the NaCl process to request that a Windows debug exception
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// handler be attached to it.
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_AttachDebugExceptionHandler,
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            std::string, /* Internal process info */
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            bool /* Result */)
73cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
74cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Notify the browser process that the NaCl process has bound the given
75cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// TCP port number to use for the GDB debug stub.
76cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)IPC_MESSAGE_CONTROL1(NaClProcessHostMsg_DebugStubPortSelected,
77cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     uint16_t /* debug_stub_port */)
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used by the NaCl process to query a database in the browser.  The database
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// contains the signatures of previously validated code chunks.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL1_1(NaClProcessMsg_QueryKnownToValidate,
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            std::string, /* A validation signature */
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            bool /* Can validation be skipped? */)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used by the NaCl process to add a validation signature to the validation
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// database in the browser.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(NaClProcessMsg_SetKnownToValidate,
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     std::string /* A validation signature */)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Used by the NaCl process to acquire trusted information about a file directly
9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// from the browser, including the file's path as well as a fresh version of the
9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// file handle.
941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// TODO(teravest): Remove the synchronous version of this message once initial
951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// nexe validation caching stops using this.
9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IPC_SYNC_MESSAGE_CONTROL2_2(NaClProcessMsg_ResolveFileToken,
9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                            uint64, /* file_token_lo */
9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                            uint64, /* file_token_hi */
9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                            IPC::PlatformFileForTransit, /* fd */
10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                            base::FilePath /* Path opened to get fd */)
10190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciIPC_MESSAGE_CONTROL2(NaClProcessMsg_ResolveFileTokenAsync,
1031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     uint64, /* file_token_lo */
1041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     uint64 /* file_token_hi */)
1051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciIPC_MESSAGE_CONTROL4(NaClProcessMsg_ResolveFileTokenAsyncReply,
1061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     uint64, /* file_token_lo */
1071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     uint64, /* file_token_hi */
1081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     IPC::PlatformFileForTransit, /* fd */
1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     base::FilePath /* Path opened to get fd */)
1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notify the browser process that the server side of the PPAPI channel was
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// created successfully.
1130529e5d033099cbfc42635f6f6183833b09dff6eBen MurdochIPC_MESSAGE_CONTROL4(NaClProcessHostMsg_PpapiChannelsCreated,
1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                     IPC::ChannelHandle, /* browser_channel_handle */
115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     IPC::ChannelHandle, /* ppapi_renderer_channel_handle */
1160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                     IPC::ChannelHandle, /* trusted_renderer_channel_handle */
1170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                     IPC::ChannelHandle /* manifest_service_channel_handle */)
118