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.
5 #ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_
6 #define COMPONENTS_NACL_COMMON_NACL_TYPES_H_
11 #include "base/basictypes.h"
12 #include "base/memory/shared_memory.h"
13 #include "base/process/process_handle.h"
14 #include "build/build_config.h"
15 #include "ipc/ipc_channel.h"
16 #include "ipc/ipc_platform_file.h"
19 #include "base/file_descriptor_posix.h"
23 #include <windows.h> // for HANDLE
26 // TODO(gregoryd): add a Windows definition for base::FileDescriptor
30 typedef HANDLE FileDescriptor
;
31 inline HANDLE
ToNativeHandle(const FileDescriptor
& desc
) {
34 #elif defined(OS_POSIX)
35 typedef base::FileDescriptor FileDescriptor
;
36 inline int ToNativeHandle(const FileDescriptor
& desc
) {
41 // We allocate a page of shared memory for sharing crash information from
42 // trusted code in the NaCl process to the renderer.
43 static const int kNaClCrashInfoShmemSize
= 4096;
44 static const int kNaClCrashInfoMaxLogSize
= 1024;
46 // Parameters sent to the NaCl process when we start it.
47 struct NaClStartParams
{
51 IPC::PlatformFileForTransit nexe_file
;
52 uint64_t nexe_token_lo
;
53 uint64_t nexe_token_hi
;
55 std::vector
<FileDescriptor
> handles
;
56 FileDescriptor debug_stub_server_bound_socket
;
58 bool validation_cache_enabled
;
59 std::string validation_cache_key
;
60 // Chrome version string. Sending the version string over IPC avoids linkage
61 // issues in cases where NaCl is not compiled into the main Chromium
65 bool enable_exception_handling
;
66 bool enable_debug_stub
;
67 bool enable_ipc_proxy
;
69 bool enable_dyncode_syscalls
;
71 // For NaCl <-> renderer crash information reporting.
72 base::SharedMemoryHandle crash_info_shmem_handle
;
74 // NOTE: Any new fields added here must also be added to the IPC
75 // serialization in nacl_messages.h and (for POD fields) the constructor
79 // Parameters sent to the browser process to have it launch a NaCl process.
81 // If you change this, you will also need to update the IPC serialization in
82 // nacl_host_messages.h.
83 struct NaClLaunchParams
{
85 NaClLaunchParams(const std::string
& manifest_url
,
86 const IPC::PlatformFileForTransit
& nexe_file
,
87 uint64_t nexe_token_lo
,
88 uint64_t nexe_token_hi
,
90 uint32 permission_bits
,
92 bool uses_nonsfi_mode
,
93 bool enable_dyncode_syscalls
,
94 bool enable_exception_handling
,
95 bool enable_crash_throttling
);
98 std::string manifest_url
;
99 // On Windows, the HANDLE passed here is valid in the renderer's context.
100 // It's the responsibility of the browser to duplicate this handle properly
101 // for passing it to the plugin.
102 IPC::PlatformFileForTransit nexe_file
;
103 uint64_t nexe_token_lo
;
104 uint64_t nexe_token_hi
;
107 uint32 permission_bits
;
109 bool uses_nonsfi_mode
;
110 bool enable_dyncode_syscalls
;
111 bool enable_exception_handling
;
112 bool enable_crash_throttling
;
115 struct NaClLaunchResult
{
118 FileDescriptor imc_channel_handle
,
119 const IPC::ChannelHandle
& ppapi_ipc_channel_handle
,
120 const IPC::ChannelHandle
& trusted_ipc_channel_handle
,
121 const IPC::ChannelHandle
& manifest_service_ipc_channel_handle
,
122 base::ProcessId plugin_pid
,
124 base::SharedMemoryHandle crash_info_shmem_handle
);
127 // For plugin loader <-> renderer IMC communication.
128 FileDescriptor imc_channel_handle
;
130 // For plugin <-> renderer PPAPI communication.
131 IPC::ChannelHandle ppapi_ipc_channel_handle
;
133 // For plugin loader <-> renderer control communication (loading and
135 IPC::ChannelHandle trusted_ipc_channel_handle
;
137 // For plugin <-> renderer ManifestService communication.
138 IPC::ChannelHandle manifest_service_ipc_channel_handle
;
140 base::ProcessId plugin_pid
;
143 // For NaCl <-> renderer crash information reporting.
144 base::SharedMemoryHandle crash_info_shmem_handle
;
149 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_