Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / nacl / common / nacl_types.h
blob7ce6b3f2a31fb4eb7e5a2948c72214e70fb52cfb
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_
8 #include <string>
9 #include <vector>
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"
18 #if defined(OS_POSIX)
19 #include "base/file_descriptor_posix.h"
20 #endif
22 #if defined(OS_WIN)
23 #include <windows.h> // for HANDLE
24 #endif
26 // TODO(gregoryd): add a Windows definition for base::FileDescriptor
27 namespace nacl {
29 #if defined(OS_WIN)
30 typedef HANDLE FileDescriptor;
31 inline HANDLE ToNativeHandle(const FileDescriptor& desc) {
32 return desc;
34 #elif defined(OS_POSIX)
35 typedef base::FileDescriptor FileDescriptor;
36 inline int ToNativeHandle(const FileDescriptor& desc) {
37 return desc.fd;
39 #endif
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 {
48 NaClStartParams();
49 ~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
62 // executable or DLL.
63 std::string version;
65 bool enable_exception_handling;
66 bool enable_debug_stub;
67 bool enable_ipc_proxy;
68 bool uses_irt;
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
76 // in nacl_types.cc.
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 {
84 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,
89 int render_view_id,
90 uint32 permission_bits,
91 bool uses_irt,
92 bool uses_nonsfi_mode,
93 bool enable_dyncode_syscalls,
94 bool enable_exception_handling,
95 bool enable_crash_throttling);
96 ~NaClLaunchParams();
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;
106 int render_view_id;
107 uint32 permission_bits;
108 bool uses_irt;
109 bool uses_nonsfi_mode;
110 bool enable_dyncode_syscalls;
111 bool enable_exception_handling;
112 bool enable_crash_throttling;
115 struct NaClLaunchResult {
116 NaClLaunchResult();
117 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,
123 int plugin_child_id,
124 base::SharedMemoryHandle crash_info_shmem_handle);
125 ~NaClLaunchResult();
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
134 // starting nexe).
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;
141 int plugin_child_id;
143 // For NaCl <-> renderer crash information reporting.
144 base::SharedMemoryHandle crash_info_shmem_handle;
147 } // namespace nacl
149 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_