Home | History | Annotate | Download | only in common
      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"
     10 #include "base/process/process.h"
     11 #include "build/build_config.h"
     12 #include "components/nacl/common/nacl_types.h"
     13 #include "components/nacl/common/pnacl_types.h"
     14 #include "content/public/common/common_param_traits.h"
     15 #include "ipc/ipc_channel_handle.h"
     16 #include "ipc/ipc_message_macros.h"
     17 #include "ipc/ipc_platform_file.h"
     18 #include "url/gurl.h"
     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_MEMBER(enable_crash_throttling)
     30 IPC_STRUCT_TRAITS_END()
     31 
     32 IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchResult)
     33   IPC_STRUCT_TRAITS_MEMBER(imc_channel_handle)
     34   IPC_STRUCT_TRAITS_MEMBER(ipc_channel_handle)
     35   IPC_STRUCT_TRAITS_MEMBER(plugin_pid)
     36   IPC_STRUCT_TRAITS_MEMBER(plugin_child_id)
     37 IPC_STRUCT_TRAITS_END()
     38 
     39 IPC_STRUCT_TRAITS_BEGIN(nacl::PnaclCacheInfo)
     40   IPC_STRUCT_TRAITS_MEMBER(pexe_url)
     41   IPC_STRUCT_TRAITS_MEMBER(abi_version)
     42   IPC_STRUCT_TRAITS_MEMBER(opt_level)
     43   IPC_STRUCT_TRAITS_MEMBER(last_modified)
     44   IPC_STRUCT_TRAITS_MEMBER(etag)
     45   IPC_STRUCT_TRAITS_MEMBER(has_no_store_header)
     46 IPC_STRUCT_TRAITS_END()
     47 
     48 // A renderer sends this to the browser process when it wants to start
     49 // a new instance of the Native Client process. The browser will launch
     50 // the process and return an IPC channel handle. This handle will only
     51 // be valid if the NaCl IPC proxy is enabled.
     52 IPC_SYNC_MESSAGE_CONTROL1_2(NaClHostMsg_LaunchNaCl,
     53                             nacl::NaClLaunchParams /* launch_params */,
     54                             nacl::NaClLaunchResult /* launch_result */,
     55                             std::string /* error_message */)
     56 
     57 // A renderer sends this to the browser process when it wants to
     58 // open a file for from the Pnacl component directory.
     59 IPC_SYNC_MESSAGE_CONTROL1_1(NaClHostMsg_GetReadonlyPnaclFD,
     60                             std::string /* name of requested PNaCl file */,
     61                             IPC::PlatformFileForTransit /* output file */)
     62 
     63 // A renderer sends this to the browser process when it wants to
     64 // create a temporary file.
     65 IPC_SYNC_MESSAGE_CONTROL0_1(NaClHostMsg_NaClCreateTemporaryFile,
     66                             IPC::PlatformFileForTransit /* out file */)
     67 
     68 // A renderer sends this to the browser to request a file descriptor for
     69 // a translated nexe.
     70 IPC_MESSAGE_CONTROL3(NaClHostMsg_NexeTempFileRequest,
     71                      int /* render_view_id */,
     72                      int /* instance */,
     73                      nacl::PnaclCacheInfo /* cache info */)
     74 
     75 // The browser replies to a renderer's temp file request with output_file,
     76 // which is either a writeable temp file to use for translation, or a
     77 // read-only file containing the translated nexe from the cache.
     78 IPC_MESSAGE_CONTROL3(NaClViewMsg_NexeTempFileReply,
     79                      int /* instance */,
     80                      bool /* is_cache_hit */,
     81                      IPC::PlatformFileForTransit /* output file */)
     82 
     83 // A renderer sends this to the browser to report that its translation has
     84 // finished and its temp file contains the translated nexe.
     85 IPC_MESSAGE_CONTROL2(NaClHostMsg_ReportTranslationFinished,
     86                      int /* instance */,
     87                      bool /* success */)
     88 
     89 // A renderer sends this to the browser process to report an error.
     90 IPC_MESSAGE_CONTROL2(NaClHostMsg_NaClErrorStatus,
     91                      int /* render_view_id */,
     92                      int /* Error ID */)
     93 
     94 // A renderer sends this to the browser process when it wants to
     95 // open a NaCl executable file from an installed application directory.
     96 IPC_SYNC_MESSAGE_CONTROL2_3(NaClHostMsg_OpenNaClExecutable,
     97                             int /* render_view_id */,
     98                             GURL /* URL of NaCl executable file */,
     99                             IPC::PlatformFileForTransit /* output file */,
    100                             uint64 /* file_token_lo */,
    101                             uint64 /* file_token_hi */)
    102